Home > front end >  How to do a post request with axios
How to do a post request with axios

Time:11-18

I am trying to do a post request with axios but it does not work. This is the request I want to do.

I tried like this:

await axios.post(
    'https://api.searchads.apple.com/api/v4/campaigns/XXXX/adgroups/targetingkeywords/find',
    {
        headers: {
            "Authorization": "Bearer "   accessToken,
            "X-AP-Context": "orgId=XXXX"
        },
        data: data
    });

CodePudding user response:

try this

var config = {
  method: 'post',
  url: 'https://api.searchads.apple.com/api/v4/campaigns/{campaignId}/adgroups/targetingkeywords/find',
  headers: {
    'Content-Type': 'application/json'
  },
  data: data
};
axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });
  • Related