Socket
Socket
Sign inDemoInstall

lesca-fetcher

Package Overview
Dependencies
2
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    lesca-fetcher

Integrate fetch for easier use


Version published
Weekly downloads
79
increased by393.75%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

NPM React React React React React NPM

Integrate fetch for easier use.

Installation

npm install lesca-fetcher --save

Usage

import Fetcher, { contentType, formatType } from 'lesca-fetcher';

Fetcher.install({
  hostUrl: 'https://yourhost.com/api/',
  contentType: contentType.JSON,
  formatType: formatType.JSON,
});

Fetch.setJWT('Fsr.956b6.67ktJGr'); // if necessary


<button
  onClick={() => {
    const path = '/save';
    const data = { name: 'myName', age: '18' };
    Fetcher.post(path, data).then((respond) => {
      console.log(respond);
    });
  }}
>post</div>;

<button
  onClick={() => {
    const path = '/get';
    Fetcher.get(path).then((respond) => {
      console.log(respond);
    });
  }}
>get</div>;

Development

Methods

methoddescriptiondefault
.install(config:object)install first
.post(api:string, data:object)POST
.get(api:string)GET
.setJWT(token):stringset JWT Token
.postStringify(api:string, data:object):stringpost and stringify
.mergePath(api:string):stringget full path
config
const config = {
  hostUrl: 'https://www.yourHost.com/api/', // string
  contentType: contentType.JSON, // enum contentType.JSON || contentType.URL_ENCODED
  formatType: formatType.JSON, // enum formatType.JSON || formatType.string
};

Features

  • maintain if necessary

Keywords

FAQs

Last updated on 05 Dec 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc