Skip to content

Commit

Permalink
feat: verbose Failed to fetch error (#6938)
Browse files Browse the repository at this point in the history
* feat: verbose Failed to fetch error

* refactor: disable console.error in src/core/plugins/spec/actions.js

Co-authored-by: Tim Lai <timothy.lai@gmail.com>
  • Loading branch information
mathis-m and tim-lai committed Feb 24, 2021
1 parent b3e08ff commit 4db2edc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 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
16 changes: 10 additions & 6 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 @@ -476,7 +476,11 @@ export const executeRequest = (req) =>
} )
.catch(
err => {
console.error(err)
// console.error(err)
if(err.message === "Failed to fetch") {
err.name = ""
err.message = "**Failed to fetch.** \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 4db2edc

Please sign in to comment.