Home > database >  How do i tell postman to scan a response for a number greater than 0?
How do i tell postman to scan a response for a number greater than 0?

Time:10-02

I have a script set up here

// the condition check
if (pm.response.json().totalPages === "1") {
    
    then change the method
    pm.variables.set("method", "POST")

    //call the same request again using setNExtRequest
    // pm.info.reqeustName gives current request's name
    postman.setNextRequest(pm.info.send)

how do i set it so that it runs when totalpages is greater than 0?

CodePudding user response:

I don't know data type of totalPages so I provide 2 solution for 2 cases:

-If totalPages is string:

if (parseInt(pm.response.json().totalPages) > 0)

-If totalPages is number:

if (pm.response.json().totalPages > 0)
  • Related