question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AjaxObservable: Redirections (including Not Modified) are wrapped in AjaxError.

See original GitHub issue

RxJS version: 5.5.6 / stable

Code to reproduce:

const request: AjaxRequest = { 
  ...requestThatWillReturnAStatusCodeAbove299Below400
}

Observable
  .ajax(request)
  .subscribe(console.log, console.error)

Expected behavior: I get the AjaxResponse in the console.log, just like any 2XX response.

Actual behavior: image

Additional information: https://github.com/ReactiveX/rxjs/blob/94156a214f905555b6e57bc3f7cf965629028406/src/internal/observable/dom/AjaxObservable.ts#L368

Over here for some reason it defines only status between 200 and 300 (Exclusive) to be “next” worthy. The rest is all piped to an AjaxError. Status codes starting at 400 should error, but the (1XX,) 2XX and 3XX should all be valid responses.

Redirects are (rightly so) not handled, but it should not be an error. Since you get the raw AjaxResponse anyway, you’ll need handling regardless; but why make a “regular case” (think 304 Not Modified, or a 302 Found) a wrapped result into AjaxError.

https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 4XX and 5XX are errors.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
claudiordgzcommented, Mar 8, 2018

I’m grabbing this! ✋

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to manage a redirect request after a jQuery Ajax call
I perform an AJAX request that has 2 possible responses: one that redirects the browser to a new page and one that replaces...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found