i am writing a pre-requist script in Postman in order to get a token. The post request goes fine from the console, but i can not find and parse it in the code.
const POSTtoken = {
url: 'http://localhost:888/api/login?username=THEanswere&password=42',
method: 'POST',
headers: {"Content-Type": "application/json"},
}
pm.sendRequest(POSTtoken,function(err, response){
pm.globals.set("apiToken", response['apiToken']); /*HERE I HAVE THE PROBLEM*/
})
basically i would like to catch the body from the post request. Is there any mathod? i am missing something? and thanks in adnvace for the support.
FIND A SOLUTION.
I didi parsed the response.
basically:
pm.sendRequest(token,function(err, response){
jsontoken= response.json()
pm.globals.set("apiToken", jsontoken['apiToken']);
})
ill leave the solution hopefully is usefull to some one else.
FIND A SOLUTION.
I didi parsed the response.
basically:
pm.sendRequest(token,function(err, response){
jsontoken= response.json()
pm.globals.set("apiToken", jsontoken['apiToken']);
})