'postman Pre-request Scropt Unexpected token u in JSON at position 0
I have a post man collection that every route has a Pre-request Script
like this
const loginUrl = pm.environment.get("reportingUrl") + "auth/login";
console.log(loginUrl)
pm.sendRequest({
url: loginUrl,
method: 'POST',
header: {
'content-type': 'application/json',
'X-CustomHeader': '7cadd7a13b4ba65c0db1dcc6d4bb29ab'
},
body: {
mode: 'raw',
raw: JSON.stringify({"username": pm.environment.get("companyUser"),
"password": pm.environment.get("companyPass") })
}
}, function (err, res) {
pm.environment.set("auth", res.json().token);
});
when I send the request the red dot appears in the right of `Pre-request Script and this error shows up
There was an error in evaluating the Pre-request Script:Error: Unexpected token u in JSON at position 0
these requests are working on another computer.
any idea why this is happening ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|