Missing response value on ajax result.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 31.7k
- Forks
- 3k
- PR merge metrics
- No merged PRs in 30d
Description
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:
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/dom/ajax';
Observable.ajax({
url: window.location.origin + "/api/book/load",
method: "POST",
responseType: "json",
body: {
key: "userKey",
sessionId: "oisudofiu"
},
headers: {
"Accept": "application/json, text/plain, */*",
"cache-control": "no-cache"
}
}).subscribe(
xhr => console.log("LOADED ", JSON.stringify(xhr, null, 2)),
error => console.log("ERROR ", JSON.stringify(error, null, 2)),
() => console.log("COMPLETE"))
Expected behavior:
Get a response with result information
Actual behavior:
Missing response information on Ajax response
{
"originalEvent": {
"isTrusted": true
},
"xhr": {},
"request": {
"async": true,
"crossDomain": false,
"withCredentials": false,
"headers": {
"Accept": "application/json, text/plain, */*",
"cache-control": "no-cache",
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
},
"method": "POST",
"responseType": "json",
"timeout": 0,
"url": "http://localhost:8888/api/book/load",
"body": "key=userKey&sessionId=oisudofiu"
},
"status": 200,
"responseType": "json",
"response": null
}
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:
{
"data": "\"Result of book loaded\"",
"status": 200,
"statusText": "OK",
"headers": {
"date": "Wed, 05 Oct 2016 16:27:40 GMT",
"cache-control": "no-cache",
"expires": "Mon, 01 Jan 1990 00:00:00 GMT",
"server": "Development/1.0",
"content-length": "27",
"content-type": "application/json;charset=utf-8"
},
"config": {
"transformRequest": {},
"headers": {
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/x-www-form-urlencoded"
},
"timeout": 0,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"method": "post",
"baseURL": "http://localhost:8888/api",
"url": "http://localhost:8888/api/book/load",
"data": "key=user&sessionId=password"
},
"request": {}
}
Thanks a lot for any help.
(EDIT by @blesh to add code color formatting)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Observable.ajax entry point and reproduce the POST request shown in the issue using the stated RxJS version. Compare the Ajax response with the endpoint's JSON result and verify that the response field contains the returned value rather than null.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- api, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100