Skip to content

tiaanduplessis/fetch-response-enhancer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fetch-response-enhancer

package version package downloads standard-readme compliant package license make a pull request

A nicer response object

Table of Contents

About

Provides a nicer response object for fetch request that tries to convert to appropriate content type. Heavily based on trae.

Install

This project uses node and npm.

$ npm install fetch-response-enhancer
$ # OR
$ yarn add fetch-response-enhancer

Usage

import fetchResponseEnhancer from 'fetch-response-enhancer'

fetch('https://jsonplaceholder.typicode.com/posts/1')
  .then(fetchResponseEnhancer)
  .then(console.log) // Object {config: Object, ok: true, headers: Headers, status: 200, statusText: ""…}

fetch('https://jsonplaceholder.typicode.com/')
  .then(res => fetchResponseEnhancer(res, { bodyType: 'text' })) // manually set bodyType
  .then(console.log) // {config: Object, ok: true, headers: Headers, status: 200, statusText: ""…}

Contribute

  1. Fork it and create your feature branch: git checkout -b my-new-feature
  2. Commit your changes: git commit -am 'Add some feature'
  3. Push to the branch: git push origin my-new-feature
  4. Submit a pull request

License

MIT

About

A nicer response object

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published