Closed jayudhandha closed 6 years ago
// Try this request
const auth = {
headers: {Authorization:'JWT ' + localStorage.getItem('token')}
}
axios.get('http://yourapi.com',auth).then(result => {
console.log(result.data)
})
//in post request
const auth = {
headers: {Authorization:'JWT ' + localStorage.getItem('token')}
}
//note:auth will be 3rd parameter in post request
axios.post('http://yourapi.com',{somekey:'some value'},auth).then(result => {
console.log(result.data)
})
//Please try this
axios({ method: "POST", "url": "your url", "": "",--input parameters "headers": { "content-type": "application/x-www-form-urlencoded" , "authorization": "Basic " + sessionStorage.getItem('id_token')--id_token is my token variable name } }).then ( items => { this.response = result.data;
}, error => { console.error(error); this.error=error; });
@jayudhandha Did you find a solution for this? I am getting facing a very similar issue.
@stalagadadeevi Yes, I am able to make it work. Please let me know your issue with some description.
Thanks!
I am trying to call post API of aws Cognito (Token endpoint). It is perfectly working in my postman client. But I am facing the issue in my VueJS code.
Below is my code snippet.
test.vue
I am successfully getting "code" value from Login Endpoint In above code, HTTP is the object imported from other javascript which is below.
http-common.js
I am not sure but the issue is that in my postman, I have used 'application/x-www-form-urlencoded' option in body + header. And here i am not able to set this value in body.
I thing my header and 'application/x-www-form-urlencoded' option in body is not getting set properly.
I am getting HTTP Code: 400