1.0.1 • Published 7 years ago

sfetch v1.0.1

Weekly downloads
4
License
ISC
Repository
github
Last release
7 years ago

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

1.0.1

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.2.1

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago