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

axios error responses opens debugging #101

Open
vzaidman opened this issue Jan 10, 2018 · 2 comments
Open

axios error responses opens debugging #101

vzaidman opened this issue Jan 10, 2018 · 2 comments

Comments

@vzaidman
Copy link

i have the following code in my program:

return fetchFromMock(src, fetchingOptions)
  .catch(() => fetchFromNetwork(src, fetchingOptions))

for every "resource" in my application, i decide in build time if it should be mocked or not.

so i'm ok with fetchFromMock fails.

now, for some reason, when axios-mock-adapter fails, chrome enters debugging mode instead of just moving on to the "catch" function

image

i'd like a way to prevent this.

@vzaidman vzaidman changed the title error object is always logged and causing debugging axios error responses opens debugging Jan 10, 2018
@ctimmerm
Copy link
Owner

Can you show what the fetchFromMock implementation looks like?

@vzaidman
Copy link
Author

vzaidman commented Jan 10, 2018

export function fetchFromMock(src, {responseType}) {
  return axiosInstance.get(
      URI(src).filename(),
      {responseType}
    ))
    .then(res => res.data)
}

and this is how the mock is created

function mock(zip) {
  return Promise.all(values(zip.files).map(addFileToAdapter))
}

function addFileToAdapter(file) {
  const name = file.name
  const reader = getFileExtension(name) === 'svg' ? 'text' : 'blob'

  return file.async(reader).then(data => {
    return adapter.onGet(name).reply(200, data)
  })
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants