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

249
Views
Next Js - How to retrieve data from the api requiring authorization (via axios)?

enter image description here

user = Cookies.get("user")

I can't get access to this road. I used cookies to store user data including the token. Please I need Help

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think your using Strapi CMS and request method for authenticated roots must be POST not GET here the example :

const {data ,status} = await 
   axios.post('https://localhost:1337/posts',{
       headers : { 
           Authorization: `Bearer ${token}`
        }
   });
 if(status === 200){
   setData(data)
  }else{
   console.log('eeror')
   }

make sure to mark the find method from strapi admin otherwise you will get 403 error in strapi user has jwt not token so make sure the token is the jwt which come from strpai when user login!

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!