app.post(“/search”, async (req,res)=>{
console.log(req.body)
const keywords = "keywords="+ req.body.keyword+"&";
const locationName = "locationName="+req.body.location;
try {
const result = await axios.get(API_URL + keywords + locationName,{
auth:{ username: API_KEY,
password:""
}
});
//Unsure how to send big long query prams
console.log(JSON.stringify(result.results));
res.render("index.ejs", { content: JSON.stringify(result.data)});
} catch (error) {
console.error(error.code);
res.render("index.ejs",{ contnet: JSON.stringify(error)});
}
});
This is the code I’m running in the hopes to get a response from Reeds API.
But I keep getting 401 error code.
On the docs it says I should use basic auth with username as my API key and password blank
https://www.reed.co.uk/developers/Jobseeker
Here’s the weird part which I can’t understand. I can use this same API call on postman and I get the response that I want but for some reason I can’t get it when I run on a local host.
Cayman Fitzhugh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.