// 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 })
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter