David Michael Gang
David Michael Gang

Reputation: 7299

error with angular-jwt and typescript

I use a variable

private $http:ng.IHttpService;

then i use a get call

this.$http({
                    url: url
                    skipAuthorization: true,
                    method: 'GET',
                    params:dataToBeSent
                })

The skipAuthorization flag is a flag used by angular-jwt, which causes it not to send the jwt.

I get the TypeScript error:

Error TS2345: Argument of type '{ url: string; skipAuthorization: boolean; method: string; params: { ..' is not assignable to parameter of type 'IRequestConfig'. Object literal may only specify known properties, and 'skipAuthorization' does not exist in type 'IRequestConfig'.

How can I fix this error?

Upvotes: 0

Views: 221

Answers (1)

MartyIX
MartyIX

Reputation: 28646

This makes my TypeScript compiler happy:

let conf = {
    url: url,
    skipAuthorization: true,
    method: 'GET',
    params:dataToBeSent
} as IRequestConfig;

this.$http(conf);

Upvotes: 3

Related Questions