(url, query, token)
| 6 | import TextEditor from "@courselit/rich-text"; |
| 7 | |
| 8 | export 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 | |
| 29 | export const capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1); |
| 30 |
no outgoing calls
no test coverage detected