Returning the status of a REST API

I have a front end REST API to temporarily display information for a user based on what they enter in. It works well when the entry is valid. However, if the entry is not valid, the last valid data remains. So to the user, it would appear the entry is still valid.

I am trying to look for some sort of return variable accessible in weweb’s formulas as to whether the REST API has a currently successful response or not. ‘isfetched and fetching’ doesn’t denote whether the fetch was successful.


I can only think of the alternative of performing the REST API call within a workflow instead of as an overall collection. Creating a temporary variable with the data I want from that rest API call. This doesn’t seem like a clean solution, so I wanted to check first.

You probably want to get the result from the form action, which is found by clicking on the lightning bolt icon shown in the attached image.


If you are not using a form selection then you will need to look at what is returned from the {}data element that you have in your first image. The {}data length will either be 0 or or {}data will be null/empty.
If you control the endpoint you can also send a status value back such as isValid=true or isValid=false

Yeah I guess my question is, can you get that response outside of a workflow and if I don’t control the endpoint as it is an external API.

I was hoping there might be some JS reference to keep the design simpler.

Well this is NOT necessarily the answer, but WeWeb does have built in support for Axios (Axios API | Axios Docs) sample Axios call from Axios API | Axios Docs
image
And return the data on success or return an error value on failure.
There are some posts on this site where people ask questions about and use axios
Search results for 'axios' - WeWeb Community
which may give you some insight.

1 Like