So I used an invalid API key and the API response is correct with 403, however, using the client here, it doesn't catch this as error. According to MDN, fetch's returned promise won't reject on HTTP error status. This patch checks and throws an Error when response is NOT ok!
Example code below:
client.photos.curated()
.then((result) => console.log(result)) // always goes here
.catch(err => console.error(err)) // never goes here
So I used an invalid API key and the API response is correct with
403
, however, using theclient
here, it doesn'tcatch
this as error. According to MDN,fetch
's returned promise won't reject on HTTP error status. This patch checks and throws anError
when response is NOT ok!Example code below: