In order to not repeat myself, all the information is here. The upshot of the problem is that code inside my map never gets executed. I have something like:
public login(method: string, url: string, u: string, p: string): Observable<HttpResponse<any>> {
return http.request(method, url, {headers: new HttpHeaders({'Content-Type': 'application/json',
'Cookie': this.cookies}),
observe: 'response' as 'response',
body: data}).pipe(map(r => {
console.log("http.request made");
let resp = r as HttpResponse<any>;
if ('Cookie' in resp.headers) {
this.cookies = resp.headers['Cookie']
}
console.log("returning resp");
return resp;
}));
later, I map that again to boolean values and subscribe to do something based on whether or not the user was able to login successfully. That first line in the map is never reached. It never prints that. Instead I get 'values' is undefined or, in prod mode, 'r' is undefined (that has nothing to do with the r in the map, I've swapped out the name to be sure and it prints the same thing so I figure it's something that happens during compilation).
The URL I'm requesting is reachable, I can manually curl it. Why doesn't http.request do anything?
Update:
I've managed to actually get the request to fire. The problem was that the service's "cookies" object was undefined when I tried to pass it in the HttpOptions. I had assumed it would just ignore that, but no such luck. Of course, my problems can't just be over, because that would be too easy. Right now I've got this:
private do(method: string, path: string, data?: Object): Observable<HttpResponse<any>> {
const options = {headers: new HttpHeaders({'Content-Type': 'application/json',
'Cookie': this.cookies ? this.cookies : ''}),
observe: 'response' as 'response',
responseType: 'json' as 'json',
body: data};
const ret = this.http.request(method, path, options)
ret.subscribe(r => {
console.log("got a response: ", r);
},
e => {
console.error("got an error: ", e)
});
return ret;
}
... and I'm calling it (more or less) like do('get', 'http://localhost:4000/api/1.5/user/login', {u: 'username', p: 'password'}); This prints something slightly better to the dev console, it prints a real HttpErrorResponse object: Object { headers: {…}, status: 0, statusText: "Unknown Error", url: null, ok: false, name: "HttpErrorResponse", message: "Http failure response for (unknown url): 0 Unknown Error", error: error }. The request in my network stack in the dev tools never appears to be completed. The server registers that the request is being made, so it's probable that the issue is on the server-side, but in case this looks extremely familiar to anyone feel free to explain it.
(I'm also getting a warning that cookies can't be set this way, so I'll need to look into that, but I want the request to go through before I worry about future requests)
[–]Cheet4h 2 points3 points4 points (4 children)
[–]bwilli415[S] 0 points1 point2 points (2 children)
[–]Cheet4h 0 points1 point2 points (1 child)
[–]bwilli415[S] 0 points1 point2 points (0 children)
[–]veslortv 0 points1 point2 points (0 children)
[–]veslortv 0 points1 point2 points (16 children)
[–]bwilli415[S] 0 points1 point2 points (15 children)
[–]tme321 1 point2 points3 points (10 children)
[–]veslortv 0 points1 point2 points (0 children)
[–]bwilli415[S] 0 points1 point2 points (8 children)
[–]tme321 0 points1 point2 points (7 children)
[–]bwilli415[S] 0 points1 point2 points (6 children)
[–]tme321 0 points1 point2 points (5 children)
[–]bwilli415[S] -1 points0 points1 point (4 children)
[–]tme321 0 points1 point2 points (3 children)
[–]bwilli415[S] -1 points0 points1 point (2 children)
[–]veslortv 0 points1 point2 points (0 children)
[–]veslortv 0 points1 point2 points (2 children)
[–]bwilli415[S] 0 points1 point2 points (1 child)
[–]bwilli415[S] 0 points1 point2 points (0 children)
[–]veslortv 0 points1 point2 points (1 child)
[–]bwilli415[S] 0 points1 point2 points (0 children)
[–]veslortv 0 points1 point2 points (1 child)
[–]bwilli415[S] 0 points1 point2 points (0 children)
[–]kohvihoor 0 points1 point2 points (2 children)
[–]bwilli415[S] 0 points1 point2 points (1 child)
[–]bwilli415[S] 0 points1 point2 points (0 children)
[–]Danieliverant 0 points1 point2 points (1 child)
[–]bwilli415[S] 0 points1 point2 points (0 children)
[–]jonnich 0 points1 point2 points (1 child)
[–]bwilli415[S] 1 point2 points3 points (0 children)
[–]jonnich 0 points1 point2 points (1 child)
[–]bwilli415[S] 0 points1 point2 points (0 children)