1.2.0 • Published 7 years ago

@ozylog/fetch v1.2.0

Weekly downloads
1
License
SEE LICENSE IN LI...
Repository
github
Last release
7 years ago

@ozylog/fetch

Travis npm

Installation

npm install @ozylog/fetch

Usage Example

fetch()

import {fetch} from @ozylog/fetch;

const response1 = await fetch('/users.html');
const body1 = await response.text();

const response2 = await fetch('/users.json');
const body2 = await response.json();

fetchJson()

// @flow

import {fetchJson} from @ozylog/fetch;

type ResponseType = {
  status: number,
  body: Object
};

const response1: ResponseType = await fetchJson('/user.json');
const response2: ResponseType = await fetchJson({
  url: '/user.json',
  method: 'POST',
  body: JSON.stringify({hello: 'world'})
});
const response3: ResponseType = await fetchJson({
  url: '/user.json',
  method: 'GET',
  query: {
    ids: [1, 2],
    country: 'AU'
  }
}); // /user.json?ids[]=1&ids[]=2&country=AU

fetchGraphql()

// @flow

import {fetchGraphql} from @ozylog/fetch;

type ResponseType = {
  status: number,
  body: Object
};

const response1: ResponseType = await fetchGraphql({
  url: '/graphql',
  query: `{
    user {
      _id
      firstName
      lastName
      email
    }
  }`,
  variables: null
});

License

MIT

1.2.0

7 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago