2.0.3 • Published 4 years ago

@mikkelfrederiksen/fetcher v2.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Ajax fetcher

This package makes it eazy to use fetch on website

Npm install

npm i @mikkelfrederiksen/fetcher

Usage

import fetcher from "https://unpkg.com/@mikkelfrederiksen/fetcher@2.0.3/fetcher.js";

this line will import everything you need.

When you have imported the package you need to use it.

GET Method

When you use the 'GET' Method you need to change 'METHOD' to get and feed the function 2 parameters. First a link to the api. Then the key for your api.

fetcher.get("LINK", "API Key")
.then(response => console.log(response))

POST Method

It's almost the same as 'GET'. Swich 'METHOD' to post and add the same 2 parameters as in the get method and add another one that is gonna be the data that has to be added to the api.

the data has to be done in a specific way. It has to be an object that is in a variable.

var data = { first_name: 'example' }

That variable is the one you put as the 3. parameter

fetcher.post("LINK", "API Key", data)
.then(response => console.log(response))

PATCH Method

the 'PATCH' method is set up the same way as the 'POST' method only things that is different is that the METHOD has to be changed to patch

fetcher.patch("LINK", "API Key", data)
.then(response => console.log(response))

DELETE Method

The 'DELETE' Method is most like the get method the only thing different is the METHOD.

fetcher.delete("LINK", "API Key")
.then(response => console.log(response))

This will delete the place you are in the api.

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago