Add support for multi request polling
Summary
- Adds support for polling multiple endpoints
- If using multiple endpoints, does not poll completed endpoints (e.g. if 2 out of 5 endpoints return
200
, it stops polling them).
Context
The Security Reports
MR Widget request to poll multiple endpoints. Our current API does not have support for that. This MR adds a new fetch
method which returns an array of functions, which will be used to create a separate poll
for each of them.
Example usage
// extensions/security_reports/index.js
{
enablePolling: true,
fetchMultiData() {
return [
this.fetchReport(this.sastEndpoint, "SAST"),
this.fetchReport(this.dastEndpoint, "DAST")
]
},
fetchReport(endpoint, reportType) {
if (!endpoint) {
return Promise.resolve();
}
return axios.get(endpoint).then((r) => ({ ...r, data: { ...r.data, reportType } }));
},
}
Related to #361757 (closed)
Edited by Savas Vedova