Question

I am using a library (found here) that pulls product data from a BigCommerce store.

The library uses curl in conjunction with a couple of data points (username, API path, and API token) that point to a specific store. Users provide this data on our site to pull products from their BigCommerce store.

The library collects data from various pages where it is stored, for example here: https://store-5m4hu6.mybigcommerce.com/api/v2/options.json If you click on this link you will see that it asks for a username and password. The username and password are the username and API token that I mention above. Our code pulls data properly when the data is entered properly, but if any of the three values are not correct our page, where the data is submitted, appears to get stuck loading indefinitely.

I see the note "If the request fails the error details will be stored in the $error var." in the library but I am unclear on where that is manifested.

Can anyone offer advice for how to handle this? Thank you

Was it helpful?

Solution

When an error occurs the details will be stored in the $error var. For example the following code will print out an error on failure.

$var = $store->get('/products');
if(isset($var) {
    do something;
} else {
    print_r($error);
}

A 401 will not error as quickly, but after some minutes of trying it should behave the same and return the 401 error details within the $error var.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top