Cannot resolve all parameters error (migrated to angular 5)


#1

Uncaught Error: Can’t resolve all parameters for Event: ([object Object], [object Object], [object Object], [object Object], [object Object], [object Object], ?, [object Object], [object Object], [object Object], [object Object], [object Object], [object Object], [object Object], [object Object]).

Which Http should to use? angular common http?? or angular http?

Thanks a lot!!!


#2

this error is occured because you dont parse the JSON data
can you show me your json data in console ?


#3

The latest version of angular ionic supports is 4.4.4 I don’t think angular 5 is supported yet.


#4

With Angular >= 4.3 they introduced HttpClientModule which gonna replace HttpModule
HttpModule was still there but marked as deprecated

@angular/common/http => HttpClient
@angular/http => Http

Maybe https://blog.angular-university.io/angular-http/ as start point


#5

cli packages: (/home/marinoraul/deventy/git/deventy/node_modules)

@ionic/cli-utils  : 1.16.0
ionic (Ionic CLI) : 3.16.0

global packages:

cordova (Cordova CLI) : 7.1.0 

local packages:

@ionic/app-scripts : 1.3.12
Cordova Platforms  : android 6.3.0
Ionic Framework    : ionic-angular 3.8.0

System:

Android SDK Tools : 26.1.1
Node              : v8.6.0
npm               : 4.6.1 
OS                : Linux 4.4

Environment Variables:

ANDROID_HOME : /home/marinoraul/Downloads/

Misc:

backend : pro

Ionic Framework: ^3.8.0
Ionic App Scripts: 1.3.12
Angular Core: ^4.4.4
Angular Compiler CLI: ^4.4.4
Node: 8.6.0
OS Platform: Linux 4.4
Navigator Platform: Linux x86_64
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36

not working for me


#6

could you be less specific?

what’s not working? same result as before?
did you load HttpClientModule in your app root module?
how does your provider/httpClient request code looks like?
how do you parse the results you displayed above?


#7

Yes the same error as before
I have loaded HttpClientModule
How i must to parse http now??? I am messy about this

Thanks


#8

Well as long as you don’t display code it’s difficult to understand what’s going on…


#9

Your app-scripts version is not compatible with your ionic-angular version.


#10

this.http.post(URL_USER_CREATE_TOKEN, params, options)
// .map(res => res.json())
.subscribe(
data => {
console.log(“create custom data”, data)
this.storage.set(‘id_token’, data)
resolve(data);
},
err => {
console.log("failure creating user custom token: " + err);
}
);


#11

Thx for the code. You are using this.http which means that you are using HttpModule

So in your root module you should check that you are loading HttpModule from @angular/http

Not sure but I see that you commented // .map(res => res.json()), since you are using HttpModule the mapping is not automatic, therefor you should maybe try to uncomment this line

Also I found this example which my give you some hints about params and options

let book = {id: 1, title: 'Awesome'};
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
this.http.post(this.url, book, options).map(res => res.json())

And like @AaronSterling noticed, your app-scripts version doesn’t fit your ionic-angular version


#12

No, this.http is HttpClient from angular/common/http but i dont know how to manipulate data after call

var headers = new HttpHeaders();
headers.set(‘Content-Type’, ‘application/x-www-form-urlencoded’)
var options = { headers: headers, withCredentials: true};
let params = this.getParams({
‘uid’ : deviceId
})


#13

Typescript Error
Property or signature expected.
node_modules/@angular/common/http/src/client.d.ts
post(url: string, body: any | null, options: {
data => {
headers?: HttpHeaders;


#14

My bad :wink:

So here’s a working HttpClientModule post example (taken from my app)

let headers: HttpHeaders = new HttpHeaders();
headers.append('Content-Type', 'application/json');

let body = {  something: 'value' };

this.httpClient.post('https://myurl.com', body, {headers: headers})
            .subscribe((result: any) => {
                console.log(result);
            }, (errorResponse: HttpErrorResponse) => {
                console.error(errorResponse);
            });

Hope that help


#15

Can i use this AuthHttp with new HttpClient???


#16

can you show me your import file and constructor parameter .


#17

this is my error:

09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1396
Property or signature expected.

L1395:  post<T>(url: string, body: any | null, options: {
L1396:                  data => {
L1397:      headers?: HttpHeaders;

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1396
’,’ expected.

L1395:  post<T>(url: string, body: any | null, options: {
L1396:                  data => {
L1397:      headers?: HttpHeaders;

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1397
’,’ expected.

L1396:              data => {
L1397:  headers?: HttpHeaders;
L1398:  observe: 'response';

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1397
Property destructuring pattern expected.

L1396:              data => {
L1397:  headers?: HttpHeaders;
L1398:  observe: 'response';

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1397
’,’ expected.

L1396:              data => {
L1397:  headers?: HttpHeaders;
L1398:  observe: 'response';

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1398
Identifier expected.

L1397:  headers?: HttpHeaders;
L1398:  observe: 'response';
L1399:  params?: HttpParams;

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1398
’,’ expected.

L1397:  headers?: HttpHeaders;
L1398:  observe: 'response';
L1399:  params?: HttpParams;

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1399
’,’ expected.

L1398:  observe: 'response';
L1399:  params?: HttpParams;
L1400:  reportProgress?: boolean;

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1399
Property destructuring pattern expected.

L1398:  observe: 'response';
L1399:  params?: HttpParams;
L1400:  reportProgress?: boolean;

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1399
’,’ expected.

L1398:  observe: 'response';
L1399:  params?: HttpParams;
L1400:  reportProgress?: boolean;

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1400
’,’ expected.

L1399:  params?: HttpParams;
L1400:  reportProgress?: boolean;
L1401:  responseType?: 'json';

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1400
Property destructuring pattern expected.

L1399:  params?: HttpParams;
L1400:  reportProgress?: boolean;
L1401:  responseType?: 'json';

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1400
’,’ expected.

L1399:  params?: HttpParams;
L1400:  reportProgress?: boolean;
L1401:  responseType?: 'json';

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1401
’,’ expected.

L1400:  reportProgress?: boolean;
L1401:  responseType?: 'json';
L1402:  withCredentials?: boolean;

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1401
Property destructuring pattern expected.

L1400:  reportProgress?: boolean;
L1401:  responseType?: 'json';
L1402:  withCredentials?: boolean;

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1401
’:’ expected.

L1400:  reportProgress?: boolean;
L1401:  responseType?: 'json';
L1402:  withCredentials?: boolean;

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1402
’,’ expected.

L1401:      responseType?: 'json';
L1402:      withCredentials?: boolean;
L1403:  }): Observable<HttpResponse<T>>;

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1402
Property destructuring pattern expected.

L1401:      responseType?: 'json';
L1402:      withCredentials?: boolean;
L1403:  }): Observable<HttpResponse<T>>;

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1402
’,’ expected.

L1401:      responseType?: 'json';
L1402:      withCredentials?: boolean;
L1403:  }): Observable<HttpResponse<T>>;

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1398
Duplicate identifier ‘(Missing)’.

L1397:  headers?: HttpHeaders;
L1398:  observe: 'response';
L1399:  params?: HttpParams;

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1398
A parameter initializer is only allowed in a function or constructor implementation.

L1397:  headers?: HttpHeaders;
L1398:  observe: 'response';
L1399:  params?: HttpParams;

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1400
Duplicate identifier ‘boolean’.

L1399:  params?: HttpParams;
L1400:  reportProgress?: boolean;
L1401:  responseType?: 'json';

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1401
Duplicate identifier ‘(Missing)’.

L1400:  reportProgress?: boolean;
L1401:  responseType?: 'json';
L1402:  withCredentials?: boolean;

[09:15:27] typescript: node_modules/@angular/common/http/src/client.d.ts, line: 1402
Duplicate identifier ‘boolean’.

L1401:      responseType?: 'json';
L1402:      withCredentials?: boolean;
L1403:  }): Observable<HttpResponse<T>>;

IMPORTS:

HttpClientModule,
JwtModule.forRoot({
jwtOptionsProvider: {
provide: JWT_OPTIONS,
useFactory: jwtOptionsFactory,
deps: [Storage]
}
}),

export function jwtOptionsFactory(storage: Storage) {
return {
tokenGetter: () => {
return storage.get(‘id_token’);
}
}
}


An example in the service:

return new Promise(resolve => {

        var headers = new HttpHeaders();
        headers.append('Content-Type', 'application/json')
        var options = { headers: headers, withCredentials: true };
        let params  = {
            'uid' : deviceId
        }

        this.authHttp.post(URL_USER_CREATE_TOKEN, params, options)
            // .map(res => res.json())
            // .pipe(
            //     map(data => {
            //         console.log("create custom data", data)
            //         this.storage.set('id_token', data)
            //         resolve(data);
            //     })
            //     // catchError(error => {
            //     //     console.log(error)
            //     // })
            // )
            .subscribe((data: any) => {
                console.log("create custom data", data)
                this.storage.set('id_token', data)
                resolve(data);
            }, (err: HttpErrorResponse) => {
                console.log("failure creating user custom token: " + err);
            }
        );
    });

#18

#19

Maybe not the solution, but I noticed that you don’t resolve/reject the promise in case there is an error…would that help?

I mean:

return new Promise((resolve, reject) => { // <----- Add reject

    ...

    this.authHttp.post(URL_USER_CREATE_TOKEN, params, options)
        .subscribe((data: any) => {
            ...
            resolve(data);
        }, (err: HttpErrorResponse) => {
            ...
            reject(err); // <--------------------- Reject
        }
    );
});

#20

Another idea, not sure again, update npm, remove node_modules and npm install again