I'm trying to get access token from indeed API developers:
API seems working tested by postman, is there any problem with my fetch?
CodePudding user response:
you should use
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/x-www-form-urlencoded");
var urlencoded = new URLSearchParams();
urlencoded.append("grant_type", "client_credentials");
urlencoded.append("client_id",
"10efaf31aee65fb0b3dfe149c1e7c902c6c909bd02b1bec27c0a1ba1ae600bd4");
urlencoded.append("client_secret",
"Mtabdk9KbUulH9WQSvK5dvm3FTDWRflWJXjpcHiqNn4KozUBXRfBMA02MnTl01uK");
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: urlencoded,
redirect: 'follow'
};
fetch("https://apis.indeed.com/oauth/v2/tokens?", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));