Exceptions handling
Sometimes an exception can occur within a method call. It can happen for a number of reasons. In any case you need to handle these exceptions on your own.
For your convenience if it’s an HTTP exception we modify and throw it in the following format:
{
status: {status}, //Response status from the server
json: {...} //JSON detals from the server
}
An example: you haven’t passed storeId into the setUp method and now is trying to pull the products (don’t do this!).
{
Buddi.setUp({});
Buddi.getProducts().catch(error => {
console.error(error);
});
}
You’ll see the exception in your console
Moreover Buddi throws an event every time when an API call returns not a 2xx response. The specific events which Buddi throws will be described below