HereToLearn_
HereToLearn_

Reputation: 1190

TypeScript : Cannot invoke an expression whose type lacks a call signature

I am new to typescript. Basically I have a typescript GET function where I want to pass an ID to get that particular record back. I am getting this error on the return line. I researched this before posting here but could not get something close to my scenario. Help appreciated!

Error TS2349 Cannot invoke an expression whose type lacks a call signature.

private getRecordRequestUrl = 'http://localhost/Service/api/ReservationRequest/GetRequestById';

 getRecordRequest(RequestId: number): Promise<ReservationModel[]> {
        return this.http.get(this.getRecordRequestUrl(RequestId))
            .toPromise()
            .then(response => response.json().Data as ReservationModel[])
            .catch(this.handleError);
}

Upvotes: 0

Views: 5372

Answers (2)

borkovski
borkovski

Reputation: 978

this.getRecordRequestUrl is not a function, it's just a string. If you want to add RequestId to it, you should concatenate the value, e.g.: return this.http.get(this.getRecordRequestUrl + '/' + RequestId)

Upvotes: 2

FarmaStron
FarmaStron

Reputation: 36

getRecordRequestUrl is a string, and not a function

But in line return this.http.get(this.getRecordRequestUrl(RequestId)) you call it like it would be a function.

Upvotes: 0

Related Questions