(path, args: { target?: Target })
| 9 | |
| 10 | type Target = "production" | "staging" | "local"; |
| 11 | const reload = async (path, args: { target?: Target }) => { |
| 12 | const { target } = args; |
| 13 | const apiUrl = |
| 14 | target === "production" |
| 15 | ? process.env.API_URL_PRODUCTION |
| 16 | : process.env.API_URL; |
| 17 | if (!apiUrl) |
| 18 | throw new Error( |
| 19 | `API_URL or API_URL_PRODUCTION is not defined, target is: ${target}` |
| 20 | ); |
| 21 | const url = getUrl(path, apiUrl); |
| 22 | console.log("// reload"); |
| 23 | console.log(path); |
| 24 | console.log(url); |
| 25 | const response = await fetch(url, { |
| 26 | method: "GET", |
| 27 | }); |
| 28 | const result = await response.text(); |
| 29 | console.log(result); |
| 30 | return { result, url }; |
| 31 | }; |
| 32 | |
| 33 | export const reloadAPISurveys = async (args) => { |
| 34 | return await reload("reinitialize-surveys", args); |
no test coverage detected