1.0.5 • Published 6 years ago

ngxfetch v1.0.5

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

npm version

ngxfetch

Installation

npm install --save ngxfetch

Usage

import { request } from 'ngxfetch'

request.get('http://example.com')
    .then(response => console.log(response)) // response as JSON
    .catch(error => console.log(error)) // error object { status, message }
import NGXFetch from 'ngxfetch'

const request = new NGXFetch(options)
request.get('http://example.com')
    .then(response => console.log(response)) // response as JSON
    .catch(error => console.log(error)) // error object { status, message }

Methods

request.get(url, options?)
request.delete(url, options?)
request.post(url, data, options?)
request.put(url, data, options?)
request.patch(url, data, options?)

Default Options

const options = {
    cache: 'default', // default, no-store, reload, no-cache, force-cache, only-if-cached
    credentials: 'same-origin', // same-origin, omit, include
    timeout: 30000, // request timeout 30s by default
    headers: {
        'Accept': 'application/json, text/plain, */*',
        'Content-Type': 'application/json'
    },
    mode: 'cors' // same-origin, no-cors, cors
}

TODO

  • d.ts file
  • canceling request
  • tests coverage
1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago