(method: string)
| 38 | }; |
| 39 | |
| 40 | const buildUrl = (method: string) => { |
| 41 | const baseUrl = `http://localhost${apiPath}`; |
| 42 | if (method === 'GET' || method === 'DELETE') { |
| 43 | const url = new URL(baseUrl); |
| 44 | if (qArg) { |
| 45 | url.searchParams.set('q', JSON.stringify(qArg)); |
| 46 | } |
| 47 | if (otherArgs) { |
| 48 | Object.entries(otherArgs).forEach(([key, value]) => { |
| 49 | url.searchParams.set(key, String(value)); |
| 50 | }); |
| 51 | } |
| 52 | return url.toString(); |
| 53 | } |
| 54 | return baseUrl; |
| 55 | }; |
| 56 | |
| 57 | const executeRequest = async (method: string, body?: any) => { |
| 58 | const url = buildUrl(method); |
no test coverage detected