@freepi/core
TypeScript icon, indicating that this package has built-in type declarations

3.0.1 • Public • Published

FreePI Core Library

Description

The core library for FreePI. Contains logic that needs to be shared between packages.

Installation

How To Use

To install FreePI

$ npm install freepi

To install package individually, run the following in your terminal.

$ npm install @freepi/unsplash

Features:

  • RequestBuilder
  • requests
  • utils

How To Use

To import the whole core library:

import { core } from "freepi";

# OR

import core from "@freepi/core";

requests

To use the requests library:

Import the request methods from the requests object

Available methods are:

  • get
  • post
  • del
  • put

All methods take two arguments: a url (or path) and a config object. The config object is where additional information like headers, data, or query parameters are passed.

To use requests methods

import { requests } from '@freepi/core';

const { get, post, del, put } = requests;

const queryParams = {
  id: 100,
};

get<Todo>('https://my.site.com/api/todos', { params: queryParams });
// the request will return an Axios promise of the type specified

To use customReqInit:
customReqInit allows use of request methods using a custom instance of axios you can optionally pass a config object which will be used to create the custom axios instance.

import { customReqInit } from '@freepi/core';

const requests = customReqInit({ baseURL: 'https://my.app.com' });
// all native methods available in the request library will
// now use the custom axios instance
requests.get('/path'); // will use baseURL set using config

Bug Reports and Feedback

Any bug reports or feedback for this library should be directed to the github issues page

Readme

Keywords

none

Package Sidebar

Install

npm i @freepi/core

Weekly Downloads

1

Version

3.0.1

License

MIT

Unpacked Size

50.2 kB

Total Files

16

Last publish

Collaborators

  • alexgaiser