Allow to optionally set axios params in urlData

This commit is contained in:
davelopez
2022-07-26 13:48:18 +02:00
parent 8b6030f67e
commit 8ec4fa4bf4
+3 -2
View File
@@ -2,11 +2,12 @@ import axios from "axios";
import { getAppRoot } from "onload/loadConfig";
import { rethrowSimple } from "utils/simple-error";
export async function urlData({ url, headers }) {
export async function urlData({ url, headers, params }) {
try {
console.debug("Requesting data from: ", url);
headers = headers || {};
const { data } = await axios.get(`${getAppRoot()}${url}`, { headers });
params = params || {};
const { data } = await axios.get(`${getAppRoot()}${url}`, { headers, params });
return data;
} catch (e) {
rethrowSimple(e);