I am using sendRequest function to verify if there are any data in the API or not.
If there is some data then I will proceed and execute my logic.
Sometimes there will be empty response as well. just like below
Since the response is empty, I should not execute my logic, but everytime the logic is being executed,
Any idea how I can stop going to else condition
pm.sendRequest(createGetTariffsRequest(), (error, response) => {
if (error) {
console.error(error);
} else {
if (response!= null) {
logic to create new data
}
What status code is being returned when it has an empty response. Hopefully it will be a 204 - no content, which you should be able to use in your IF statement.
Unfortunately in both cases the response code is 200.
When there is data and without data , response code is 200.
So I can’t use this in the IF condition.
I am looking for some condition based on the body in the response