UNPKG

@pnp/sp

Version:

pnp - provides a fluent api for working with SharePoint REST

23 lines 1.07 kB
import { combine, isUrlAbsolute } from "@pnp/core"; import { BrowserFetchWithRetry, DefaultParse } from "@pnp/queryable"; import { DefaultHeaders, DefaultInit } from "./defaults.js"; import { RequestDigest } from "./request-digest.js"; export function SPBrowser(props) { if ((props === null || props === void 0 ? void 0 : props.baseUrl) && !isUrlAbsolute(props.baseUrl)) { throw Error("SPBrowser props.baseUrl must be absolute when supplied."); } return (instance) => { instance.using(DefaultHeaders(), DefaultInit(), BrowserFetchWithRetry(), DefaultParse(), RequestDigest()); if (isUrlAbsolute(props === null || props === void 0 ? void 0 : props.baseUrl)) { // we want to fix up the url first instance.on.pre.prepend(async (url, init, result) => { if (!isUrlAbsolute(url)) { url = combine(props.baseUrl, url); } return [url, init, result]; }); } return instance; }; } //# sourceMappingURL=spbrowser.js.map