feat: add apilayer as provider for fixer api (#127)

feat: add apilayer as provider for fixer api
feat: update exchange rate when saving api key
This commit is contained in:
Miguel Ribeiro
2024-02-20 00:37:38 +01:00
committed by GitHub
parent e726b5c0bf
commit 0f19dd688f
17 changed files with 142 additions and 31 deletions
+4 -1
View File
@@ -477,18 +477,21 @@ function addFixerKeyButton() {
document.getElementById("addFixerKey").disabled = true;
const apiKeyInput = document.querySelector("#fixerKey");
apiKey = apiKeyInput.value.trim();
const provider = document.querySelector("#fixerProvider").value;
fetch("endpoints/currency/fixer_api_key.php", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: `api_key=${encodeURIComponent(apiKey)}`,
body: `api_key=${encodeURIComponent(apiKey)} & provider=${encodeURIComponent(provider)}`,
})
.then(response => response.json())
.then(data => {
if (data.success) {
showSuccessMessage(data.message);
document.getElementById("addFixerKey").disabled = false;
// update currency exchange rates
fetch("endpoints/currency/update_exchange.php?force=true");
} else {
showErrorMessage(data.message);
document.getElementById("addFixerKey").disabled = false;