Handle parameters more gracefully with the mixin. (#198)

This commit is contained in:
FireMasterK
2021-06-15 17:07:35 +05:30
committed by GitHub
parent b69cc4c848
commit 546e47df9b
6 changed files with 33 additions and 51 deletions

View File

@@ -55,7 +55,12 @@ const mixin = {
num = parseInt(num)
return num.toLocaleString('en-US')
},
fetchJson: function (url, options) {
fetchJson: function (url, params, options) {
if (params) {
url = new URL(url);
for (var param in params)
url.searchParams.set(param, params[param])
}
return fetch(url, options).then(response => {
return response.json();
});