Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: verbose Failed to fetch error #6938

Merged
merged 4 commits into from Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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**See console** for more information. \n**Possible Reasons:** \n - CORS \n - Network Failure \n - URL scheme must be \"http\" or \"https\" for CORS request."
tim-lai marked this conversation as resolved.
Show resolved Hide resolved
}
specActions.setResponse(req.pathName, req.method, {
error: true, err: serializeError(err)
})
Expand Down