// Get wrapper const get = async (url, callback) => { const response = await fetch(url) const status = await response.status if (callback) callback[status](await response.json()) } // Get usage based callback get(url, { 200: body => doSomething, 401: body => showSignInModal, 403: body => redirectToSafeArea, 422: body => showModalWithInstruction })