i hope you are doing well. Today I have this problem: I have this 2 functions:
const search_words = async (word, question) => {
let options = {
method: 'GET',
url: `https://google.com/complete/search?client=psy-ab&gl=fr&lr=lang_fr&q=${word}%20${question}`,
headers: {
'Accept': 'application/json; charset=utf-8',
'Content-Type': 'application/json',
}
};
return axios.request(options).then(function (response) {
console.log(response.data[1])
return response.data[1]
}).catch(function (error) {
console.log(error);
});
}
app.post('/api/related-questions', async (req, res) => {
const question = req.body.question
let questionsReturn = {}
let qui = search_words('qui', question).then(res => questionsReturn['qui'] = res)
let quoi = search_words('quoi', question).then(res => questionsReturn['quoi'] = res)
let pourquoi = search_words('pourquoi', question).then(res => questionsReturn['pourquoi'] = res)
let que = search_words('que', question).then(res => questionsReturn['que'] = res)
let ou = search_words('ou', question).then(res => questionsReturn['ou'] = res)
Promise.all([qui, quoi, pourquoi, que, ou]).then(() => {
res.json(questionsReturn)
})
})
If I make the request to the Google API with Postman, I will get the searches with the correct chars:

But when I make it with Axios and my func I get this chars:

Im missing any configuration ? Thanks for reading <3