Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

86
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!