I have two functions, one works the other gives me this 404 error:
/get[object%20Object] 404 (Not Found)
The function getNews gives me that error, I used a console.log to see values of both functions, and I get the same: this.newId = "1", so I call both method with an string using the id of the "New" but it only works the onVote method.
Why on getNews case I got an Object on the request, and on onVote I have the id?
This is the component.ts file:
export class NewDetailsComponent implements OnInit
{
params = new URLSearchParams();
options = new RequestOptions({ withCredentials: true });
oneNew: New;
newId: string;
constructor(public http: Http, private activatedRoute: ActivatedRoute)
{ }
ngOnInit()
{
this.activatedRoute.params.subscribe(params =>
{
this.newId = params['id']
});
this.getNews(this.newId)
}
getNews(id: string)
{
this.params.set('id', id)
this.options.search = this.params
this.http
.get(ApiConfig.API_URL + 'news/get' + this.options)
.toPromise()
.then(response =>
{
this.oneNew = <New>response.json()
})
}
onVote(id: string)
{
this.params.set('id', id.toString())
this.options.search = this.params
this.http
.get(ApiConfig.API_URL + 'news/Vote', this.options)
.toPromise()
}
.get(ApiConfig.API_URL + 'news/get' + this.options)and.get(ApiConfig.API_URL + 'news/Vote', this.options). There might be something wrong with+and,.