Skip to content

Instantly share code, notes, and snippets.

@tnhu
Created June 2, 2016 04:05
Show Gist options
  • Save tnhu/fb44d534f45f029d5cfe45bedbbb23c5 to your computer and use it in GitHub Desktop.
Save tnhu/fb44d534f45f029d5cfe45bedbbb23c5 to your computer and use it in GitHub Desktop.
fetch2
/*
fetch() only rejects when network error occurs (offline), fetch2() rejects all non-200 statuses
*/
const fetch2 = api => fetch(api).then(res => res.ok ? res : Promise.reject(res));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment