Closed
Description
I have a link like;
http://10.254.147.183:7777/auth/oauth/token?grant_type=password&username=demo&password=12345
and I want to write the parameters of this link into a variable. I mean those 3 parameters, which are grant_type, username and password should be sent as a variable.
I tried to convert it to a variable but it didn't work when I put the variable into the post method.
My variable looks like;
const x = {
grant_type:'password',
username:'demo',
password:'12345'
}
My post method;
axios.post('http://10.254.147.183:7777/auth/oauth/token',x, {
headers: { 'Content-Type': ['application/x-www-form-urlencoded'], 'Authorization': ['Basic Y2xpZW50OnNlY3JldA=='] }
})
.then(function(response){
console.log(response.data);
console.log(response.status);
})
.catch(function(error){
console.log(error);
});
When I write the code below, it works but when I write the code above it doesn't.
axios.post('http://10.254.147.183:7777/auth/oauth/token','grant_type=password&username=demo&password=12345', {
headers: { 'Content-Type': ['application/x-www-form-urlencoded'], 'Authorization': ['Basic Y2xpZW50OnNlY3JldA=='] }
})
.then(function(response){
console.log(response.data);
console.log(response.status);
})
.catch(function(error){
console.log(error);
});
Could you tell me how to send those parameters as a variable?
Activity
burakuluu commentedon Apr 24, 2017
My problem is solved by this answer