(path, params = {}, includeAuth = false)
| 55 | * @returns {string} - Complete URL |
| 56 | */ |
| 57 | export function buildUrl(path, params = {}, includeAuth = false) { |
| 58 | const url = new URL(path, API_BASE_URL); |
| 59 | const allParams = includeAuth |
| 60 | ? { ...params, ...getAuthQueryParam() } |
| 61 | : params; |
| 62 | Object.entries(allParams).forEach(([key, value]) => { |
| 63 | if (value !== undefined && value !== null) { |
| 64 | url.searchParams.set(key, String(value)); |
| 65 | } |
| 66 | }); |
| 67 | return url.toString(); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * @param {string} path - URL path (will be appended to API_BASE_URL) |
no test coverage detected