New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

api-request-client

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-request-client

axios request wrapper

latest
Source
npmnpm
Version
0.0.10
Version published
Maintainers
1
Created
Source

api-request-client

Build Status

axios request wrapper

Installation

  • yarn add api-request-client or npm install api-request-client

How to use

Post

import { APIRequestClient, ResponseError } from 'api-request-client';

interface User {
  name: string;
}

const createUser = async () => {
  const requestClient = new APIRequestClient({
    url: 'users',
    baseURL: 'http://localhost:8080',
  });
  try {
    const response = await requestClient
      .setMethod('POST')
      .setData({
        name: 'jiseung',
      })
      .send<User>();

    console.log(response.name);
  } catch (err) {
    if (err instanceof ResponseError) {
      if (err.errorResponse.status === 400) {
        alert('bad request');
      }
    }
  }
};

Post form-data

import { APIRequestClient, ResponseError } from 'api-request-client';

const form: FormData = new FormData();
form.append('test', '1');

const response = await request
  .setMethod('POST')
  .setBodyType('form')
  .setData(form)
  .send<Params>();

FAQs

Package last updated on 24 Apr 2019

Did you know?

Socket

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