UNPKG

@arc-publishing/sdk-sales

Version:
34 lines 1.54 kB
import { __assign, __awaiter, __generator } from "tslib"; import JSONResponseHandler from '@arc-publishing/sdk-subs-core/lib/utils/JSONResponseHandler'; import { headers, logPrefix } from './constants'; import Sales from './sales'; export default function getAddresses() { return __awaiter(this, void 0, void 0, function () { var isLoggedIn; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4, Sales._Identity.isLoggedIn()]; case 1: isLoggedIn = _a.sent(); if (!isLoggedIn) { throw new Error("".concat(logPrefix, " Missing or invalid jwt")); } return [2, fetch("".concat(Sales.apiOrigin, "/sales/public/v1/checkout/addresses"), { method: 'GET', headers: __assign({ Authorization: "Bearer ".concat(Sales._Identity.userIdentity.accessToken) }, headers) }) .then(JSONResponseHandler) .then(function (json) { if (Array.isArray(json)) { Sales.addresses = json; return json; } else { throw json; } })]; } }); }); } //# sourceMappingURL=getAddresses.js.map