-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
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)
adrian-moisa and aaronjensen
Metadata
Metadata
Assignees
Labels
No labels