saleor-apps-redis_apl/apps/apps-cli/src/lib/fetch-app-manifest.ts
2023-06-26 12:49:38 +02:00

21 lines
558 B
TypeScript

import { AppManifest } from "@saleor/app-sdk/types";
export const fetchAppManifest = async (manifestUrl: string) => {
const manifestDataResponse = await fetch(manifestUrl);
let manifestData: AppManifest;
if (!manifestDataResponse.ok) {
console.log("Error fetching manifest");
throw new Error("Error fetching manifest");
}
try {
manifestData = (await manifestDataResponse.json()) as AppManifest;
} catch (e) {
console.log("Error parsing manifest");
throw new Error("Error parsing manifest");
}
return manifestData;
};