Skip to content

Commit

Permalink
feat: verbose Failed to fetch error
Browse files Browse the repository at this point in the history
Signed-off-by: mathis-m <mathis.michel@outlook.de>
  • Loading branch information
mathis-m committed Feb 17, 2021
1 parent 429283d commit 446db33
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/core/components/live-response.jsx
Expand Up @@ -69,6 +69,7 @@ export default class LiveResponse extends React.Component {
return <span className="headerline" key={key}> {key}: {joinedHeaders} </span>
})
const hasHeaders = returnObject.length !== 0
const Markdown = getComponent("Markdown", true)

return (
<div>
Expand Down Expand Up @@ -101,9 +102,7 @@ export default class LiveResponse extends React.Component {
</td>
<td className="response-col_description">
{
isError ? <span>
{`${response.get("name")}: ${response.get("message")}`}
</span>
isError ? <Markdown source={`${response.get("name") !== "" ? `${response.get("name")}: ` : ""}${response.get("message")}`}/>
: null
}
{
Expand Down
14 changes: 9 additions & 5 deletions src/core/plugins/spec/actions.js
Expand Up @@ -256,7 +256,7 @@ export const requestResolvedSubtree = path => system => {
const isPathAlreadyBatched = requestBatch
.map(arr => arr.join("@@"))
.indexOf(path.join("@@")) > -1

if(isPathAlreadyBatched) {
return
}
Expand Down Expand Up @@ -376,9 +376,9 @@ export const executeRequest = (req) =>
let { pathName, method, operation } = req
let { requestInterceptor, responseInterceptor } = getConfigs()


let op = operation.toJS()

// ensure that explicitly-included params are in the request

if (operation && operation.get("parameters")) {
Expand Down Expand Up @@ -439,8 +439,8 @@ export const executeRequest = (req) =>
}
)
.filter(
(value, key) => (Array.isArray(value)
? value.length !== 0
(value, key) => (Array.isArray(value)
? value.length !== 0
: !isEmptyValue(value)
) || requestBodyInclusionSetting.get(key)
)
Expand Down Expand Up @@ -477,6 +477,10 @@ export const executeRequest = (req) =>
.catch(
err => {
console.error(err)
if(err.message === "Failed to fetch") {
err.name = ""
err.message = "**Failed to fetch.** \n **See console** for more information. \n**Possible Reasons:** \n - CORS \n - Network Failure \n - URL scheme must be \"http\" or \"https\" for CORS request."
}
specActions.setResponse(req.pathName, req.method, {
error: true, err: serializeError(err)
})
Expand Down

0 comments on commit 446db33

Please sign in to comment.