0
votes

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);
}
2
getRecordRequestUrl is a string. You're trying to call it in this.getRecordRequestUrl(). Exactly the kind of mistake TypeScript is there to warn you about, which it does.deceze♦

2 Answers

2
votes

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)

0
votes

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.