Hello,
I’m integrating a SQlite database by following this tutorial https://youtu.be/fE09dHu6sP0
I receive the following message:
Block-scoped variable ‘Headers’ used before its declaration.
return new Promise((resolve, reject) =>{
let Headers = new Headers() ;
I’m looking for it and I can not find a way to fix it.
my code:
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import 'rxjs/add/operator/map';
import { FilePath } from '@ionic-native/file-path';
import { HttpHeaders } from '@angular/common/http/src/headers';
let apiUrl = "http://localhost/PHP-Slim-Restful/api/";
/*
Generated class for the AuthServiceProvider provider.
See https://angular.io/guide/dependency-injection for more info on providers
and Angular DI.
*/
@Injectable()
export class AuthServiceProvider {
constructor(public http: HttpClient) {
console.log('Hello AuthServiceProvider Provider');
}
postData(credentials, type){
return new Promise((_resolve, reject) =>{
let HttpHeaders = new HttpHeaders() ;
this.http.post(apiUrl+type, JSON.stringify (credentials), HttpHeaders).subscribe(res =>{(response =>
console.log(response));
}), (err) =>{
reject(err);
}});
};
}
merci d’avance
ludo
I have no idea what the connection is between the code you posted and SQLite, but if you got that code from the video you linked, my advice would be to find another source of guidance, because what you have posted is an antipattern casserole of needlessness. For HTTP, I would start here.
in fact I had already followed the first tutorial he had done for the creation of login page and I wanted to follow with this tutorial for the registration of data provided by the user of the app
I see less than zero value in continuing to follow sources of bad code simply for the sake of familiarity, but it’s your career, not mine.
it’s not for familiarity
but as the first tutorial gave me the result that I wanted I thought that the sequel would also be good but it is not the case.
so I’m going to look for another tutorial for the database
I’m still unclear about the relationship between SQLite and the code you have posted, which seems to be trying to authenticate over HTTP.
One thing to keep in mind is that you cannot do authentication on device: SQLite on the same device as your app is completely useless for authentication purposes.
I will explain a little how I need my app.
1st page connection, 2nd page different information that the person must fill in, a button to save everything that will save in the database (to be able to be consulted by the user when he wants it via another page) and send by mail to a certain address.
here in general.