Throw an error from the back-end to the front-end

Hi Yanis.

I imagine you are still calling the function with the fetch request in your frontend?

This function is a Promise and you can handle errors as you’ll do with any other Promise, using catch()

In case you want to handle different responses from the fetch request (like 200, 404, 500), you can return those values in your backend function, and use either a switch() statement or a conditional statement to handle those different responses in the frontend.

If you can share your code, I might be able to give you more accurate options.