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

121
Views
Reactjs axios returning promise instead of value

I am trying to fetch data from from API using axios but it keeps returning a Promise

The code for nodeJs:

router.get('/isAdmin/:userId/:groupeId', async (req, res) => {
    let userId =  req.params.userId
    let groupeId =  req.params.groupeId
    let result = await db.query("select * from groupemembers where userId = ? and groupeId = ? and groupeRole = 'admin'",[userId, groupeId], function(err, result){
        if (err) console.log(err.message);
        if (result.length > 0) return res.send(true);
        else res.send(false)
    })
    return result
})

the Code for ReactJs:

 async function checkAdmin (){
        let user = JSON.parse(localStorage.getItem('userInfo'))
        let groupeId = params.groupeId
        let result = api.get(`/isAdmin/${user.id}/${groupeId}`).then(res => {
            return res.data
        })
        return result
    }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are not using the await keyword for resolving the promise

 async function checkAdmin (){
            let user = JSON.parse(localStorage.getItem('userInfo'))
            let groupeId = params.groupeId
            let result = await api.get(`/isAdmin/${user.id}/${groupeId}`).then(res => {
                return res.data
            })
            return result
        }
about 4 years ago · Juan Pablo Isaza Report
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!