-
-
Save nayzawoo/aae05dda79e80f9d9365924c86346dc7 to your computer and use it in GitHub Desktop.
Postman pre-request script to get a new JWT token before each request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pm.sendRequest({ | |
url: pm.environment.get('url') + '/login_check', | |
method: 'POST', | |
header: { | |
'Content-Type': 'multipart/form-data', | |
}, | |
body: { | |
mode: 'formdata', | |
formdata: [ | |
{ key: '_email', value: pm.environment.get('email') }, | |
{ key: '_passwd', value: pm.environment.get('password') } | |
] | |
} | |
}, | |
function(err, response) { | |
const jsonResponse = response.json(); | |
pm.environment.set('token', jsonResponse.token); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment