Open eimrek opened 3 months ago
For the REST API calls, a single module would be great, that contains all the functions that are used to call the rest api. The functions should take a baseUrl or apiUrl argument and any other custom arguments.
baseUrl
apiUrl
E.g.
async function fetchNodesPaginated( apiUrl, fullType, page, entriesPerPage = 20 ) { let url = `${apiUrl}/nodes/page/${page}`; // query parameters: url += `?perpage=${entriesPerPage}&full_type="${fullType}"&orderby=-ctime`; if (fullType.includes("process")) { url += "&attributes=true"; url += "&attributes_filter=process_label,process_state,exit_status,exit_message,process_status,exception"; } const response = await fetch(url); const result = await response.json(); return result.data.nodes; }
Note: error handling should probably be also included. And the output data format should be documented.
This will allow to easily migrate to the new REST API in the future.
For the REST API calls, a single module would be great, that contains all the functions that are used to call the rest api. The functions should take a
baseUrl
orapiUrl
argument and any other custom arguments.E.g.
Note: error handling should probably be also included. And the output data format should be documented.
This will allow to easily migrate to the new REST API in the future.