UNPKG

lin3s-sylius-shop-api-client

Version:

JavaScript client on top of SyliusShopApiPlugin to build integrations with ease.

20 lines (16 loc) 526 B
import axios from 'axios'; import session, {CartDoesNotExist} from "../session"; export default config => ({cartId} = {}) => { return new Promise((resolve, reject) => { try { axios.get(`${config.baseUrl}/shop-api/carts/${cartId ? cartId : session(config).Cart.id()}`) .then(response => resolve(response.data)) .catch(error => reject(error)); } catch (exception) { if (exception instanceof CartDoesNotExist) { return resolve(null); } throw exception; } }); };