0

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);
}
1
  • 1
    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. Commented Apr 6, 2017 at 13:29

2 Answers 2

2

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)

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.