Added error handling for non-CORS requests.
This commit is contained in:
parent
52426bc1a4
commit
127364e8a4
@ -3407,7 +3407,7 @@ const OperationConfig = {
|
||||
"<br><br>",
|
||||
"You can add headers line by line in the format <code>Key: Value</code>",
|
||||
"<br><br>",
|
||||
"This operation will throw an error for any status code that is not 200, unless the 'Ignore status code' option is checked.",
|
||||
"The status code of the response, along with a limited selection of exposed headers, can be viewed by checking the 'Show response metadata' option. Only a limited set of response headers are exposed by the browser for security reasons.",
|
||||
].join("\n"),
|
||||
run: HTTP.runHTTPRequest,
|
||||
inputType: "string",
|
||||
|
@ -126,6 +126,10 @@ const HTTP = {
|
||||
|
||||
return fetch(url, config)
|
||||
.then(r => {
|
||||
if (r.status === 0 && r.type === "opaque") {
|
||||
return "Error: Null response. Try setting the connection mode to CORS.";
|
||||
}
|
||||
|
||||
if (showResponseMetadata) {
|
||||
let headers = "";
|
||||
for (let pair of r.headers.entries()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user