UNPKG

@arc-publishing/sdk-amp

Version:
30 lines 1.41 kB
import { __awaiter, __generator } from "tslib"; import { isAPIErrorResponse } from '@arc-publishing/sdk-subs-core/lib/utils/APIErrorResponse'; import JSONResponseHandler from '@arc-publishing/sdk-subs-core/lib/utils/JSONResponseHandler'; import { headers } from './constants'; import { getOptions, getValidURL } from './utils'; import AMP from './amp'; export default function authenticateAMPReaderID(ampReaderId) { return __awaiter(this, void 0, void 0, function () { var options, url; return __generator(this, function (_a) { switch (_a.label) { case 0: return [4, getOptions({ method: 'GET', headers: headers })]; case 1: options = _a.sent(); url = typeof window !== 'undefined' ? getValidURL(AMP.apiOrigin) : AMP.apiOrigin; return [2, fetch("".concat(url, "/sales/public/v1/amp/").concat(ampReaderId), options) .then(JSONResponseHandler) .then(function (json) { if (isAPIErrorResponse(json)) { throw json; } else { return json; } })]; } }); }); } //# sourceMappingURL=authenticateAMPReaderID.js.map