-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Missing response value on ajax result. #2007
Comments
Interesting, it makes me wonder if it has something to do with it being a POST or not. |
@maierson is this, by chance, something that is open source that we can look at? Do you have a minimum replication case we can see? Or perhaps could we get a copy of the raw HTTP response so we can try to spoof it locally and replicate the issue? |
Hi Ben, Thanks for looking into this. The project is not open source but I'm at the beginning of porting a large project to react and want to get all my (ahem) ducks in a row before I do all the porting. I'll put a boilerplate together as soon as I get a chance. Some more details. I'm using typescript 2.0, redux-observable. I'm calling a resteasy java endpoint. The error also misses the error message. If I wrap a promise with I've also tried with Rx v4 + rx-dom I'll look into getting you the raw HTTP response - just have to restore the setup. |
@Blesh - i did some more digging and figured out the reason for result missing. It's because the server actually sends back a text response and the post call was configured to get a json call. Once i change the ajax call configuration to The axios promise is configured with This probably should raise an error instead of returning a response with empty result. The error not providing a message issue still remains. Here is the HTTP call info (see the Response containing the error message returned from the server):
And this is the error payload from the observer's catch method
|
I see. This seems like something we can fix. I'll give it some thought. |
I have run into the same issue. The code works as expected under Chrome. But under Firefox the Ajax response is blank. Changing the Hope the extra information helps. |
Whew, am I glad for your comment @jjasonclark—at work I use Firefox Dev, but at home, I use the regular FF (version 50), and I thought I was going crazy ("this thing was just working at the office!"). I can confirm that I am getting an |
I am working on 3rd party API that talks json, but sends simple string as errors, which should be fine hence a string is a valid json format. But its not because the error object always return null if the response is a string. I assume
|
Guys, any workaround for this issue, I got this issue too when server trying to redirect by sending ..... so there is no way to redirect to login based on the response. |
Found a benchmark comparing xhr +
(I reran this benchmark on Chrome 69) The workaround for us would be to set ajax({
url: 'https://api.trello.com/1/batch/',
responseType: 'text',
}).pipe(map(r => ({...r, response: JSON.parse(r.response), responseType: 'json'})))
.subscribe(console.log, e => {
console.log('fail', e.response)
}, console.log) Example here: Maybe rxjs make the IE fallback code the primary code and remove the |
Exactly the same I did to solve my problem. We have to be careful if requestType is Json or text we can parse. Otherwise i.e. blob we just move on |
Hey guys, a guly workaround is not a solution. ajax.get or ajax.post need to have a response value if ther is any given by the server. I face the same issue here using ajax.post to send params and receive a string. its just null. Its a no go bug. Please fix it as soon as possible or remove the method completely if you cannot make it work to not confuse further developers. |
We have unfortunately used a forked version of RXJS because of this bug. Has there been any pushback to submit a PR to fix? |
What's the status on this? It's opened since 2016 and seems like it's still an issue. |
hey guys! 1, loading chartjs from a CDN using rxjs/ajax: ajax("https://cdn.jsdelivr.net/npm/chart.js@2.9.3/dist/Chart.min.js")
.subscribe(
data => {
console.log(data.response);
},
error => console.error(error)
);
/*
RESULT: null
*/ I tended to give up and made friend with axios ajax({
url: "https://cdn.jsdelivr.net/npm/chart.js@2.9.3/dist/Chart.min.js",
responseType: "blob"
}).subscribe(
data => {
const script = document.createElement("script");
script.src = URL.createObjectURL(data.response);
document.body.appendChild(script);
script.onload = function() {
console.log(typeof Chart);
};
},
error => console.error(error)
);
/*
RESULT: 'function' meaning chartjs was fetched successfully. Lol
*/ Thank you for your help! |
So it will continue? |
Hi guys,
I'm trying to do a simple ajax call and get a response but i get an answer with null response value.
RxJS version:
"rxjs": "^5.0.0-beta.12"
Code to reproduce:
Expected behavior:
Get a response with result information
Actual behavior:
Missing response information on Ajax response
Additional information:
If i make the same call with
axios
against the same (jersey) REST endpoint I get back the correct data. The endpoint is configured to ignore params and respond with "Result of book loaded" string. Here is the axios response:Thanks a lot for any help.
(EDIT by @Blesh to add code color formatting)
The text was updated successfully, but these errors were encountered: