Module: common/jsonOrThrow

Methods

(static) jsonOrThrow() → {Promise}

Helper function when making fetch() requests. Checks if the response is ok and converts it to JSON, otherwise it throws.
Source:
Returns:
Type
Promise
Example
fetch('/_/list').then(jsonOrThrow).then(json => {
     // Do something with the parsed json here.
   }).catch(errorMessage);