UNPKG

sb-mig

Version:

CLI to rule the world. (and handle stuff related to Storyblok CMS)

30 lines (29 loc) 1.03 kB
import Logger from "../utils/logger.js"; const getAllStories = async (args, config) => { const { spaceId, storiesFilename } = args; Logger.warning("Trying to get all stories from Content Hub..."); const queryParams = `spaceId=${spaceId}&storiesFilename=${storiesFilename}`; const url = `${config.contentHubOriginUrl}/getStories?${queryParams}`; const authorizationToken = config.contentHubAuthorizationToken; if (config.debug) { console.log("This is url: ", url); } try { const response = await fetch(url, { method: "GET", headers: { Authorization: authorizationToken, }, }); if (!response.ok) { throw new Error(`Error fetching stories: ${response.statusText}`); } const data = await response.json(); return data; } catch (error) { console.error("Error fetching stories:", error); throw error; } }; export const contentHubApi = { getAllStories };