create a axios post in in javascript

index.tsx
// Import axios library
const axios = require('axios');

// Data to be sent
const data = {
  key: 'value'
};

// URL to post the data
const url = 'https://api.example.com';

// Sending a POST request using Axios
axios.post(url, data)
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.error(error);
  });
345 chars
20 lines

related categories

gistlibby LogSnag