AUTOMATICALLY STORING TOKENS

Jan 25, 2024

Stop copying & pasting the response key value to your variable, and let's automate this action using the coming marvelous way with considering that you are returning a response similar to the below schema:

 

{
    "key": "success",
    "msg": "You have logged in successfully",
    "data": {
        "name": "Mahmoud Ramadan",
        "token": "1|7XJ3hr2HZmQD24D9fkKYrmPB6ivCo7b9imbUP7NA"
    }
}

 

At first, I will hypothesize that you have defined a `token` variable as a Global scope. Postman has multiple tabs under the URL input, especially the Tests tab, go ahead and open it, then write the next JavaScript code:

🔐 Members-Only Deep Dive

To read the full technical content, please log in.

Login
Mahmoud Ramadan

Mahmoud Ramadan

Mahmoud is the creator of Digging Code and a contributor to Laravel since 2020.