0👍
In your axios request you’ve send your data as parameters instead of form data.
Have a look at this thread to see how to send form data: axios post request to send form data
0👍
You gotta send in the second param exactly what you’re sending into params;
So the new request would be something like this:
const data = {
grant_type: "password",
username: "test",
password: "password",
client_id: "admin-cli"
}
const url = 'http://127.0.0.1:8080/auth/realms/master/protocol/openid-connect/token'
axios.post(
url,
data, // data in the second param
{
headers: {
'content-type': 'application/x-www-form-urlencoded'
}
}).then((response) => {
console.log(response)
}).catch((error) => {
console.log(error)
})
Source:stackexchange.com