refactord pagespeed slice

This commit is contained in:
Alex Holliday committed 2024-08-17 09:50:52 -07:00
1 parent ceb8985afb
commit 10fceb6ff1
2 files changed
+31 -77

No files matched your search

+17 -10
View File
@@ -43,16 +43,23 @@ axiosInstance.getMonitorsByUserId = async (
sortOrder,
normalize
) => {
const typeQuery = types.reduce((acc, type) => acc + `&type=${type}`, "");
return axiosInstance.get(
`/monitors/user/${userId}?limit=${limit}${typeQuery}&sortOrder=${sortOrder}&normalize=${normalize}`,
{
headers: {
Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json",
},
}
);
const params = new URLSearchParams();
if (limit) params.append("limit", limit);
if (types) {
types.forEach((type) => {
params.append("type", type);
});
}
if (sortOrder) params.append("sortOrder", sortOrder);
if (normalize) params.append("normalize", normalize);
return axiosInstance.get(`/monitors/user/${userId}?${params.toString()}`, {
headers: {
Authorization: `Bearer ${authToken}`,
"Content-Type": "application/json",
},
});
};
// Updates a single monitor