Insomnia - Tricks and Tips
This is to set variable token so you don't need to keep on copy paste the bearer.
Setting token after login
This is to set variable token so you don't need to keep on copy paste the bearer.
// let's say we have this
{
"success": true,
"data": {
"token": "18|TOreJ7lLOGgdfviF8b3NdAJn8Fqo2gwx1TXhemyqav8900b31e",
"name": "User",
},
"message": "User login successfully."
}
Go to After-response

Add this
const jsonBody = insomnia.response.json();
const body = insomnia.response.json();
const token = body.data.token;
if (token) {
insomnia.environment.set("token", token);
}