Emmanuel Katto from Dubai : Efficiently Handling API Status Keys in Flutter Flow

General Conversations

Hi everyone,

I’m Emmanuel katto from Dubai, United Arab Emirates (UAE) working on an API integration where I maintain a status key in the response of all my API calls to track whether the request was successful or failed. Here’s how it works:

When I hit an API, the request is sent to the database, and the database returns a response with a status key to indicate success or failure.

For example:

status = 1 means success.

status = 2 means show an error toast.

status = 20 means expire the session.

However, here's the issue: Sometimes, the database might return a successful response even though the requested data doesn’t exist, like when I ask for data using an ID that doesn’t exist in the database. The response status will still indicate success, but the actual data returned is an error (such as an empty result). To manage this, I need to check the status key after every API call, and based on the value, I perform different actions (e.g., expire the session if status = 20, show an error if status = 2, etc.).

My question is:

Centralized Status Handling:

In Flutter Flow, is there a way to store and reference these status keys globally, so that I don’t have to manually check and update the status for each API call individually?

Is there a Substitution Keys section or something similar where I can define these status keys and check them across all APIs in one place?

Managing Status Checks:

How do you all manage this type of status-based logic for API responses in your apps? Do you use a centralized method to check and handle the status after each API call, or do you implement the checks individually for every API?

Efficient Updating of Status Keys:

If I need to update the logic for a status key (for instance, considering status = 20 as a success in some cases), how can I do this efficiently without having to update every API endpoint or call in my entire app?

Best Practices:

Any best practices or patterns you recommend for handling status keys in API responses, especially when multiple API calls need to follow the same status checking logic?

I want to avoid redundant code and make sure that my app handles the status checks in a scalable, clean way. Any insights would be greatly appreciated!

Thanks in advance!

Regards

Emmanuel Katto

1
2 replies