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

309
Views
Interceptors axios js JWT authentication with react js put & post method sending parameter and access the parameter in node express

Private Axios Code

```axiosPrivate.interceptors.request.use(function (config) {
    if(!config.headers.authorization){
        config.headers.authorization = `Bearer ${localStorage.getItem('accessToken')}`
    }
    return config;
   }```

Frontend React code

```const userInfo = user.email
        const delivery = {img,name,price,seller,stock}
        axiosprivate.put(`http://localhost:4000/stock/${productId}`, delivery, 
      userInfo)```

Node Express Code

```const token = headerAuth.split(' ')[1]
    jwt.verify(token,process.env.ACCESS_TOKEN_JWT, (err,decoded) => {
        if(err) return res.status(403).send({message: 'forbidden access'})
        
        req.decoded = decoded
        next()
    })```

and

```app.put('/stock/:id', JWTAccess, async (req, res)=>{
            const decodedEmail = req.decoded.email
            const email = req.body
            if(email === decodedEmail){
                const id = req.params.id
                const filter = {_id : ObjectId(id)}
                const updatedPD = req.body
                const options = { upsert: true };
                const updateDoc = {
                    $set: updatedPD
                }
                const result = await productCollection.updateOne(filter, updateDoc, 
            options)
                res.send(result)
            }
            else{
                res.status(403).send({message: 'forbidden access'})
            }
        })```

Please guide me, on how can I send from react js Axios put & post method sending parameter so that I will be able to receive the parameter at the backend.

Thanks in advance!

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!