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

88
Visualizações
Comparing 2 string keeps returning false

so im trying to check if the response i get back from a post request is "success".

onClick={ async () => {
    const response = await superagent.post(`http://localhost:3000/create/`).send({
        author: `${author}`,
        title: `${title}`,
        body: `${body}`,
        tag: `${tag}`,
    })
    const responseJSON = JSON.stringify(response.text)
    console.log(typeof responseJSON)

    console.log(responseJSON)
    if(responseJSON === "success"){
        
        setError('good')
    }else{
        setError('error try again')
    }
}}

ive console.logged the responseJSON and it shows that the value is infact a string and is "success" but when i compare it to "success" using the === operator it just returns false. why is this?

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