1.0.0 • Published 6 years ago

fetch-in-a-can v1.0.0

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

fetch-in-a-can

My Fetch helper for Node.js

Status: Development | Active

I maintain this helper library for use in my own projects.

examples...

const restGetCall = async () => {
    // Github REST API v3
    const endpoint = 'https://api.github.com/users/burntsugar';
    const response = await fetchInACan.fetchGetRestApi(endpoint);
    const data = await response.getBody();
    console.log(data);
    return data;
}

const graphQLCall = async () => {
    // Github GraphQL API v4
    const query = `{ user(login: "burntsugar") { bio avatarUrl(size: 200) url login name } }`;
    const payload = JSON.stringify({ query: query });
    const response = await fetchInACan.fetchPostGraphQLApi('https://api.github.com/graphql', payload, API_KEY
    );
    const data = await response.getBody();
    console.log(data);
    return response;
}

🥫 Install

npm install --save fetch-in-a-can

🥫 Use

import fetchInACan from 'fetch-in-a-can';

What's inside

rrr@burntsugar.rocks