What is the best way to know if an API has returned any data or not?

Describe the problem/error/question

I calling any API.

Sometimes the API does not return any data but is execution is successful (status: 200). How can we detect if the API has returned any data or not?

Here when the API returns some data and I need to process that data and insert the total number of items returned by the API in a DB.

Hi @YogiYang :wave:

You could use a workflow like this, with an If node to check if the API has returned data:

If data is returned, the true branch would be executed. If there’s no data and only the status response (like this), it would trigger the false branch:

3 Likes

Thanks for detailed reply.

But I am getting only these choices.

Hi @YogiYang - I’m not too sure what version of n8n you’re on, but you’ll want to update to latest in order to see the same options :+1:

I have version 1.0.5.
It is self hosted on railway.app.

I am trying to update it but as I am new to railway.app finding it hard.