tuandm / laravue

Admin dashboard for enterprise Laravel applications built by VueJS and Element UI https://laravue.dev
https://laravue.dev
MIT License
2.21k stars 655 forks source link

how to use postman to test api #311

Closed DamonSnow closed 2 years ago

DamonSnow commented 3 years ago

if i write a api, how can i use post to test my api?

zainaldeen commented 3 years ago

follow the next steps: 1- open your inspect in your browser on Network tap 2- login from your dashboard 3- in Network tap you will find a request called login click on it 4- there is another tap called Header showed click on it 5- scroll down to see the Response Header section 6- there is a header called Authorization has a value like : Bearer 133|dsind.... etc 7- copy the token without "Bearer" word and open postman 8- in section Authorization in post man choose the type to be Bearer Type and put your token in the "token" field 9- now your requests are authenticated :) 10- try to send any request from your API, if you test on localhost your requests will be like: localhost:8000/api/YOUR_ENDPOINT 11- change YOUR_ENDPOINT to endpoint from your API

zainaldeen commented 3 years ago

follow the next steps: 1- open your inspect in your browser on Network tap 2- login from your dashboard 3- in Network tap you will find a request called login click on it 4- there is another tap called Header showed click on it 5- scroll down to see the Response Header section 6- there is a header called Authorization has a value like : Bearer 133|dsind.... etc 7- copy the token without "Bearer" word and open postman 8- in section Authorization in post man choose the type to be Bearer Type and put your token in the "token" field 9- now your requests are authenticated :) 10- try to send any request from your API, if you test on localhost your requests will be like: localhost:8000/api/YOUR_ENDPOINT 11- change YOUR_ENDPOINT to endpoint from your API

if you want you could even login via post man by sending email and password then fetch the token from the response header also..