-1

Can you please help me convert the following request to axios request.

const request = require('request-promise');

const data = {name:'pte', age:30}
const options = {secret:'34444'}
const opp = {
    method: 'POST',
    uri: 'https://something',
    headers: { 'content-type': 'application/json' },
    options,
    body: JSON.stringify(data),
};

return request(opp);
Mbanda
  • 968
  • 11
  • 21

1 Answers1

1
const axios = require('axios')

const url = 'https://something'
const data = { name : 'pte', age : 30 }
const options = {
   headers : {
      'content-type' : 'application/json'
   }
}

axios.post(url, data, header)
hellikiam
  • 415
  • 2
  • 9
  • That was my first though but i got fail, since am accessing a particular gateway, but with request-promise the way it is, all goes well. – Mbanda Dec 17 '20 at 08:55