npm.io
1.0.1 • Published 9 years ago

sfetch

Licence
ISC
Version
1.0.1
Deps
1
Vulns
0
Weekly
0

Sfetch

  • package fetch

  • response add field 'json' to save backend data otherwise add field 'text'

  • body make object to JSON.stringify(object)

  • body suppport FormData or JSON (use FormData set daetaType:'formdata')

  • method support GET POST PATH DELETE

  • support timeout (default not set)

  • support header (but fetch Request header field Authorization is not allowed)

Usage

npm install sfetch --save

import sfetch from 'sfetch'

Example

GET
   sfetch.get({
        url: url,
        body: body,//Object
        timeout: 5000
    }).then((response) => {
    //response include 'json' field
    },(response)=>{
    //response include 'text' field
    });
POST
     sfetch.post({
         url: url,
         body: body,//Object or FormData
         dataType : 'formdata',// body is FormData
		   timeout: 5000
     }).then((response) => {
         //response include 'json' field
      },(response)=>{
         //response include 'text' field
      });
PATH
the same as POST
DELETE
the same as POST

####Welcome to star , Thanks