UNPKG

@upstart.gg/sdk

Version:

You can test the CLI without recompiling by running:

35 lines (33 loc) 1.05 kB
import { UnauthorizedError } from "../../../../errors.js"; //#region src/shared/datasources/external/tiktok/video/fetcher.ts const fetchTiktokVideoDatasource = async ({ options, oauth }) => { const url = `https://open.tiktokapis.com/v2/video/list/?${new URLSearchParams({ access_token: oauth.config.accessToken, fields: [ "id", "title", "video_description", "duration", "cover_image_url", "embed_link" ].join(",") }).toString()}`; const body = options; const response = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${oauth.config.accessToken}` }, body: JSON.stringify(body) }); if (!response.ok) { if (response.status === 401) throw new UnauthorizedError(`fetchTiktokVideoDatasource Error: Unauthorized.`); throw new Error(`Response status: ${response.status}`); } return await response.json(); }; var fetcher_default = fetchTiktokVideoDatasource; //#endregion export { fetcher_default as default }; //# sourceMappingURL=fetcher.js.map