{ const response = await superagent.post(`htt" /> { const response = await superagent.post(`htt" /> { const response = await superagent.post(`htt"/>

Comparing 2 string keeps returning false

80 Views Asked by At

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?

0

There are 0 best solutions below