UNPKG

@upstart.gg/sdk

Version:

You can test the CLI without recompiling by running:

20 lines (18 loc) 854 B
import { createPlaceholderReplacer, placeholderRx } from "../../utils.js"; //#region src/shared/datasources/external/http-json/fetcher.ts /** * For this fetcher, validation is done outside of the fetcher. */ const fetchHttpJSON = async ({ options, pageAttributes }) => { const replacer = createPlaceholderReplacer(pageAttributes); const url = options.url.replace(placeholderRx, replacer); const headers = {}; if (options.headers) for (const [key, value] of Object.entries(options.headers ?? {})) headers[key] = value.replace(placeholderRx, replacer); const response = await fetch(url, { headers }); if (!response.ok) throw new Error(`fetchHttpJSON Error: Response status: ${response.status}`); return response.json(); }; var fetcher_default = fetchHttpJSON; //#endregion export { fetcher_default as default }; //# sourceMappingURL=fetcher.js.map