Skip to content

Instantly share code, notes, and snippets.

@Vortexdude
Created August 4, 2023 18:25
Show Gist options
  • Save Vortexdude/424997127156db447f53bb57b18afd8d to your computer and use it in GitHub Desktop.
Save Vortexdude/424997127156db447f53bb57b18afd8d to your computer and use it in GitHub Desktop.
set variable from postman request using pre-request-script
pm.sendRequest({
url: "http://127.0.0.1:5000/login",
method: 'POST',
header: {
'accept': 'application/json',
'Content-Type': 'application/json',
'timeout': '3000'
},
body: {
mode: 'raw',
raw: JSON.stringify({
email: 'test@email.com',
password: 'test'
})
}
}, function(err, response) {
if (err) {
console.error(err)
return;
}
pm.environment.set('token', response.json().token)
console.log(response.json().token)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment