Need to migrate the following code from Postman to Bruno. Into the Postman Post-response I have this request:
pm.sendRequest({
url: `${lambdaUrl}/finxact/accountnumber/${psnNumber}`,
method: 'GET',
header: {
'qa-test-id': 'pm-test-1',
'x-api-key': `${qa_lambda_key}`
},
}, function(err, res) {
pm.expect(res).to.have.property('code', 200);
const acctNbr = res.json().data[0].acctNbr
console.log(acctNbr)
pm.environment.set("acctNbr",acctNbr)
pm.environment.set("accountNumber", acctNbr)
});
Tried with the following approach into the Bruno Post Response but it’s not working:
req.setUrl(`${lambdaUrl}/finxact/accountnumber/${psnNumber}`);
req.setMethod("GET")
req.setHeaders({
"qa-test-id": "pm-test-1",
"x-api-key": `${qa_lambda_key}`
});
const status = res.getStatus();
let responseBody = res.getBody();
console.log(responseBody)
// expect(responseBody).to.have.property('code', 200);
// expect(res.status).to.equal(200);
const acctNbr = responseBody.data[0].acctNbr
console.log(acctNbr)
bru.setEnvVar("acctNbr",acctNbr)
bru.setEnvVar("accountNumber", acctNbr)
Note: have commented the expect lines because it does not recognize expect function.