fetch-json v

A wrapper around Fetch just for JSON

Why would you fetch anything but json? ;)

fetch-json makes REST easy — it automatically:

  1. Converts the HTTP response to JSON if it's not already JSON
  2. Serializes the body payload with JSON.stringify()
  3. Adds the 'application/json' HTTP header to set the data type
  4. Appends the GET params object items to the URL
  5. Runs .json() on the response
  6. Sets credentials to 'same-origin'
fetchJson.get(url, params)

Fork it: