Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleUse HTTP response status codes to handle different outcomes

HTTP status codes provide valuable information about the outcome of the request, and based on these codes, different actions can be taken, such as further retries or error handling.

Here we are using Arithmetic Operators to capture all possible 2XX status codes.

  • If a 2XX code is returned, we are treating it as a success and returning the response message. This is typically when you would queue or perform any additional processing on the data.

  • If a code outside of the 2XX series is returned, we are logging an error. At this This stage is when you have the flexibility to handle the outcome as required - wether whether that means logging an error to trigger a notification for your team or retrying the original request.

...