MCPcopy Create free account
hub / github.com/codelitdev/courselit / queryGraphQL

Function queryGraphQL

packages/app/lib/utils.js:8–27  ·  view source on GitHub ↗
(url, query, token)

Source from the content-addressed store, hash-verified

6import TextEditor from "@courselit/rich-text";
7
8export const queryGraphQL = async (url, query, token) => {
9 const options = {
10 method: "POST",
11 headers: token
12 ? {
13 "Content-Type": "application/json",
14 Authorization: `Bearer ${token}`,
15 }
16 : { "Content-Type": "application/json" },
17 body: JSON.stringify({ query }),
18 };
19 let response = await fetch(url, options);
20 response = await response.json();
21
22 if (response.errors && response.errors.length > 0) {
23 throw new Error(response.errors[0].message);
24 }
25
26 return response.data;
27};
28
29export const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
30

Callers 2

onCourseDeleteFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected