Skip to main content

Introduction

GitHub Licensenpm versionnpm minified sizenpm total downloads

🔥warning

WIP Package!

Promise based HTTP request API

api

The api package is a Promise based HTTP/s request API, with a simple syntax.

⏰ Short Example

// Let't create our API
const api = new API({
baseURL: 'https://myapp.com', // Base Route to the Host
timeout: 10000, // After which amount of time a request times out
options: { credentials: 'include' } // Http/s Request Options from type RequestInit
});

// Now we can create our first Request to 'https://myapp.com/hello'
const response = await api.get('/hello');
console.log(response);
/*
{
data: {hello: "Jeff"}; // Response Data
timedout: false; // If Request has timedout
status: 200; // Response Status Code
raw: Response; // Raw Response from type Response
type: "application/json"; // Response Type
}
*/