Closed adriatic closed 9 years ago
I'm not sure it's related to the error. The error you are getting is coming from the router when it is trying to generate a route. It's saying that you tried to generate a parameterized route but didn't supply the parameter value to generate it from.
The more specific version of save
works -- and from the viewpoint of what data is provided, both versions are equivalent - as shown below
Somehow, I managed (did I) to close this issue, when that was not my intent.
I believe that the problem is in generic form where the two headers
"Accept", "application/json"
and "Content-Type", "application/json"
are not assumed and probably should if I am right believing that this should be default.
I would check the response.content with the configured request to see if you are getting back the data you expect and in the form you expect it.
Already did that - when using the specific version of put, the results I am getting are OK
@bryanrsmith Can you see anything wrong with the code above. It looks fine to me. I'm not sure why there would be a problem with the http service like this. I believe this has solid test coverage. The error is related to route generation though. Perhaps something is going wrong there?
@adriatic Can you show me the code that calls your save method?
Try removing the .then() continuation in the second version. The first version is returning the response, but the second is returning the response content, so the shape of the return values is different. On Tue, Jul 21, 2015 at 7:45 AM Rob Eisenberg notifications@github.com wrote:
@bryanrsmith https://github.com/bryanrsmith Can you see anything wrong with the code above. It looks fine to me. I'm not sure why there would be a problem with the http service like this. I believe this has solid test coverage. The error is related to route generation though. Perhaps something is going wrong there?
@adriatic https://github.com/adriatic Can you show me the code that calls your save method?
— Reply to this email directly or view it on GitHub https://github.com/aurelia/http-client/issues/73#issuecomment-123350434.
Sure:
import {inject} from "aurelia-framework";
import {MovieData} from "./movieData";
import {Router} from "aurelia-router";
@inject(MovieData, Router)
export class Edit {
constructor(movieData, router) {
this.data = movieData;
this.router = router;
}
activate(params) {
return this.data.getById(params.id)
.then(movie => {
this.movie = movie;
});
}
save() {
this.data.save(this.movie)
.then(movie => {
let url = this.router.generate("details", { id: movie.id});
this.router.navigate(url);
});
}
}
@bryanrsmith Second pair of eyes helps.
I was advised (some time ago) that rather than using the defaults in
I should use the request builder to be very specific:
Is this still the case? The reason for this question is that when using the first, more generic form I get