Skip to content

Instantly share code, notes, and snippets.

@ruprict
Created October 2, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruprict/5ac9af6efd18e47ffd79 to your computer and use it in GitHub Desktop.
Save ruprict/5ac9af6efd18e47ffd79 to your computer and use it in GitHub Desktop.
function deserialize(res) {
var header = res.headers.get('Content-Type');
if (!header) return res.text();
return res.headers.get('Content-Type').indexOf('application/json') > -1 ? res.json() : res.text();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment