bigcommerce/laravel-react-sample-app

401 error....I'm trying to access the cart data

Closed this issue · 3 comments

const fetchBigCommerceData = async () => {
try {
const response = await fetch('https://api.bigcommerce.com/stores/{aherf0o3nw}/v3/carts/{1c0f378e-754d-4d0e-9725-47b6b63eb43a}', {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-Auth-Token': '7bbfqce4j84ony1hvxyvqwp8qcaex9a',
'X-Auth-Client': '8nvp8k6y09jvbxxfxqkfij2oc4zdqho'
},
mode: 'no-cors'
});

  const jsonData = await response.json();
  setData(jsonData);
} catch (error) {
  console.error(error);
}

};

@Mpese-Joao you have exposed client-id and token. You might want to rotate your keys!

Try and remove the { } around the store hash and cart id
Futhermore, you need to make sure the scope of the API key permissions allows for read-only or modify the cart

Thank you so much!

@Mpese-Joao
If that solved it, please close the issue 🙂