Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

axios-endpoint

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-endpoint

Scalable and easy to use axios arch

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Axios endpoint

Manage and create axios requests without a hassle

Installation

npm i axios-endpoint

Usage

Import it
let route = require("axios-endpoint");
// es6
import route from "axios-endpoint";
(Optional) Configure axios as you like
const axios = require("axios");
axios.defaults.baseURL = "https://jsonplaceholder.typicode.com";
Use it
let endpoint = {
  getTodos: route("GET", "/todos/1").bundle(),

  getTodosBefore: route("GET", "/todos/1")
    .before(() => {
      console.log("this is gonna run before the request!");
    })
    .bundle(),

  getTodosAfter: route("GET", "/todos/1")
    .after(() => {
      console.log("this is gonna run after the request!");
    })
    .bundle(),

  getTodosBeforeAfter: route("GET", "/todos/1")
    .before(() => {
      console.log("this is gonna run before the request!");
    })
    .after(() => {
      console.log("this is gonna run after the request!");
    })
    .bundle()
};

endpoint
  .getTodos()
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.error(error);
  });
endpoint
  .getTodosBefore()
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.error(error);
  });
endpoint
  .getTodosAfter()
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.error(error);
  });
endpoint
  .getTodosBeforeAfter()
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.error(error);
  });

Callback hooks

before runs exactly before making the request

after runs exactly after making the request

Run tests

npm run test

Keywords

FAQs

Package last updated on 23 Nov 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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc