How to make an Axios POST request

Axios is a promise-based HTTP client for node.js which can be deployed both frontend and backend.


To perform a POST request using Axios and thus send data to a particular end-point use the function.


Basic POST Request

Let's import the axios package and perform a basic POST request to an end-point, which doesn't send data.


const axios = require('axios');

const res = await'');


Send Data with Axios Post Request

To send data in a POST request with Axios, pass it as the second argument of the function. In the example below, we'll send an object then catch the response with .then().


const axios = require('axios')'', {
   Name: 'John',
   LastName: 'Smith'
 .then(function (response) {
http request