Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 Error Supplied parameters do not match any signature of call target

I am trying to call post api on button click but I shows this error:

Supplied parameters do not match any signature of call target

Code:

changeStatus(id) {
    this.http.post('https://localhost:44300/api/apis/ChangeStatus/' + id)
        .subscribe(
            data => this._data = data.json(),
            err => this.logError(err)
        );
}
like image 660
Malik Kashmiri Avatar asked Jul 12 '16 09:07

Malik Kashmiri


2 Answers

post method requires at least two parameters, first 'URL', and second 'Body' and in your code you are just passing URL not body.

like image 38
Ravinder Kumar Avatar answered Sep 27 '22 21:09

Ravinder Kumar


http.post expects a body to be sent to the target host.

http.post(url, body, requestOptions)

So if you just want an empty body, because you have no additional data to send, you could do this:

changeStatus(id) {
    // mind the empty string here as a second parameter
    this.http.post('https://localhost:44300/api/apis/ChangeStatus/' + id, "") 
        .subscribe(
            data => this._data = data.json(),
            err => this.logError(err)
        );
}
like image 154
rinukkusu Avatar answered Sep 27 '22 21:09

rinukkusu