|
@@ -64,7 +64,7 @@ function cancelTryOut(endpointId) {
|
|
|
document.querySelector(`#btn-tryout-${endpointId}`).hidden = false;
|
|
|
const executeBtn = document.querySelector(`#btn-executetryout-${endpointId}`);
|
|
|
executeBtn.hidden = true;
|
|
|
- executeBtn.textContent = "Send Request 💥";
|
|
|
+ executeBtn.textContent = executeBtn.dataset.initialText;
|
|
|
document.querySelector(`#btn-canceltryout-${endpointId}`).hidden = true;
|
|
|
// Hide inputs
|
|
|
document.querySelectorAll(`input[data-endpoint=${endpointId}],label[data-endpoint=${endpointId}]`)
|
|
@@ -89,7 +89,7 @@ function makeAPICall(method, path, body = {}, query = {}, headers = {}, endpoint
|
|
|
body = JSON.stringify(body)
|
|
|
}
|
|
|
|
|
|
- const url = new URL(window.baseUrl + '/' + path.replace(/^\//, ''));
|
|
|
+ const url = new URL(window.tryItOutBaseUrl + '/' + path.replace(/^\//, ''));
|
|
|
|
|
|
// We need this function because if you try to set an array or object directly to a URLSearchParams object,
|
|
|
// you'll get [object Object] or the array.toString()
|
|
@@ -119,7 +119,7 @@ function makeAPICall(method, path, body = {}, query = {}, headers = {}, endpoint
|
|
|
headers,
|
|
|
body: method === 'GET' ? undefined : body,
|
|
|
signal: window.abortControllers[endpointId].signal,
|
|
|
- referrer: window.baseUrl,
|
|
|
+ referrer: window.tryItOutBaseUrl,
|
|
|
mode: 'cors',
|
|
|
credentials: 'same-origin',
|
|
|
})
|
|
@@ -150,7 +150,7 @@ function handleResponse(endpointId, response, status, headers) {
|
|
|
} catch (e) {
|
|
|
|
|
|
}
|
|
|
- responseContentEl.textContent = response === '' ? '<Empty response>' : response;
|
|
|
+ responseContentEl.textContent = response === '' ? responseContentEl.dataset.emptyResponseText : response;
|
|
|
isJson && window.hljs.highlightElement(responseContentEl);
|
|
|
const statusEl = document.querySelector('#execution-response-status-' + endpointId);
|
|
|
statusEl.textContent = ` (${status})`;
|
|
@@ -165,10 +165,8 @@ function handleError(endpointId, err) {
|
|
|
|
|
|
// Show error views
|
|
|
let errorMessage = err.message || err;
|
|
|
- errorMessage += "\n\nTip: Check that you're properly connected to the network.";
|
|
|
- errorMessage += "\nIf you're a maintainer of ths API, verify that your API is running and you've enabled CORS.";
|
|
|
- errorMessage += "\nYou can check the Dev Tools console for debugging information.";
|
|
|
- document.querySelector('#execution-error-message-' + endpointId).textContent = errorMessage;
|
|
|
+ const $errorMessageEl = document.querySelector('#execution-error-message-' + endpointId);
|
|
|
+ $errorMessageEl.textContent = errorMessage + $errorMessageEl.textContent;
|
|
|
const errorEl = document.querySelector('#execution-error-' + endpointId);
|
|
|
errorEl.hidden = false;
|
|
|
errorEl.scrollIntoView({behavior: "smooth", block: "center"});
|
|
@@ -177,7 +175,7 @@ function handleError(endpointId, err) {
|
|
|
|
|
|
async function executeTryOut(endpointId, form) {
|
|
|
const executeBtn = document.querySelector(`#btn-executetryout-${endpointId}`);
|
|
|
- executeBtn.textContent = "⏱ Sending...";
|
|
|
+ executeBtn.textContent = executeBtn.dataset.loadingText;
|
|
|
executeBtn.disabled = true;
|
|
|
executeBtn.scrollIntoView({behavior: "smooth", block: "center"});
|
|
|
|
|
@@ -269,6 +267,6 @@ async function executeTryOut(endpointId, form) {
|
|
|
})
|
|
|
.finally(() => {
|
|
|
executeBtn.disabled = false;
|
|
|
- executeBtn.textContent = "Send Request 💥";
|
|
|
+ executeBtn.textContent = executeBtn.dataset.initialText;
|
|
|
});
|
|
|
}
|