Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

210
Visualizações
Express & Node Server wont recognize UTF-8 Chars

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: enter image description here

But when I make it with Axios and my func I get this chars: enter image description here

Im missing any configuration ? Thanks for reading <3

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda