Error
Close
Typescript Error
Duplicate identifier ‘http’.
D:/loadlink/src/pages/fastagregister/fastagregister.ts
constructor(public navCtrl: NavController, public navParams: NavParams, public http: HttpClient, private storage: Storage) {
Typescript Error
Subsequent variable declarations must have the same type. Variable ‘http’ must be of type ‘any’, but here has type ‘HttpClient’.
D:/loadlink/src/pages/fastagregister/fastagregister.ts
constructor(public navCtrl: NavController, public navParams: NavParams, public http: HttpClient, private storage: Storage) {
Ionic Framework: 3.9.2
Ionic App Scripts: 3.1.8
Angular Core: 5.2.9
Angular Compiler CLI: 5.2.9
Node: 8.11.0
OS Platform: Windows 7
Navigator Platform: Win32
User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
fastagregister.ts
import { Component } from ‘@angular/core’;
import { IonicPage, NavController, NavParams } from ‘ionic-angular’;
import { InvoicePage } from ‘…/invoice/invoice’;
import { HttpClient, HttpHeaders } from ‘@angular/common/http’;
import { Storage } from ‘@ionic/storage’;
/**
- Generated class for the FastagregisterPage page.
- See https://ionicframework.com/docs/components/#navigation for more info on
- Ionic pages and navigation.
*/
@IonicPage()
@Component({
selector: ‘page-fastagregister’,
templateUrl: ‘fastagregister.html’,
})
export class FastagregisterPage {
public vehtype: any;
public o1: any;
public o2: any;
public o3: any;
public o4: any;
public o5: any;
public o6: any;
public o7: any;
public o8:any;
public o9:any;
public o10:any;
public add: any;
public dl: any;
public myDate: any;
public http:any;
public name:any;
public test:any;
constructor(public navCtrl: NavController, public navParams: NavParams, public http: HttpClient, private storage: Storage) {
this.storage.get('userId').then((value) => {
console.log('Testvalue is', value);
this.test = value;
});
}
ionViewDidLoad() {
console.log(‘ionViewDidLoad FastagregisterPage’);
}
register() {
let headers = new HttpHeaders();
headers.append("Content-Type", "application/json");
let body = {
action:“fastag_register”,
vehicle_type: this.vehtype,
address:this.add,
dob:this.myDate,
license_no:this.dl,
id :this.test,
image :'',
rc_no:this.o1+ this.o2 + this.o3 + this.o4 + this.o5 + this.o6 + this.o7 + this.o8 + this.o9 + this.o10,
rc:'',
rc1:''
};
console.log(JSON.stringify(body));
this.http.post(‘http://freshkhata.com/fastag_api.php’, JSON.stringify(body), {headers: headers})
.subscribe(data => {
console.log(data);
if(data['status']=='201')
{
this.navCtrl.push(InvoicePage);
}
else{
alert("RC Alerady exit");
}
});
}
next(el) {
el.setFocus();
}
navsdhfcfdbbfbf()
{
this.navCtrl.push(InvoicePage);
}
}