Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Sep 26th, 2018 62 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. .then(response => {
  2.     // Throw error cases as exceptions
  3.     if (response.status === 401) {
  4.       throw new Error('Unauthorized')
  5.     }
  6.     if (response.status != 200) {
  7.       throw new Error('Server Error')
  8.     }
  9.     // Otherwise, just async parse the body to json
  10.     return response.json()
  11.   })
  12.   .then(response => {
  13.     // Success response
  14.   })
  15.   .catch(e => {
  16.     // Failed response
  17.   })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top