Vue.js. Send get/post request with headers and parameners

Viewed 507

All I want is to create LinkedIn login component. I cannot find any information about headers and parameters. Can anyone tell me how to send GET or POST request with parameters and headers?

Here's my code with parameters. Any idea where should be headers?

await axios.get('https://www.linkedin.com/oauth/v2/authorization', {
   params: {
      response_type: 'code',
      client_id: 'MY_CODE_HERE',
      redirect_uri: 'http://localhost:8080/auth/login',
      scope: 'r_liteprofile r_emailaddress w_member_social'
   }
}).then(response => {
   console.log("INFO: " + response);
}).catch(error => {
   console.log("ERROR: " + error);
});
``
1 Answers

Add a headers part in the config object passed to axios

await axios.get('https://www.linkedin.com/oauth/v2/authorization', {
   response_type: 'code',
   client_id: 'MY_CODE_HERE',
   headers: {
     'X-Header-Name': 'header value',
   },
   redirect_uri: 'http://localhost:8080/auth/login',
   scope: 'r_liteprofile r_emailaddress w_member_social',
}).then(response => {
   console.log("INFO: " + response);
}).catch(error => {
   console.log("ERROR: " + error);
});
Related