I am new to using Angular and Ionic. While following a tutorial, I encountered the following errors:
- Cannot find name ‘Let’ (TS2304)
- Cannot find name ‘headers’. Did you mean ‘Headers’? (TS2552)
- Cannot find name ‘options’. Did you mean ‘Option’? (TS2552)
Here is the code snippet from my access-providers.ts file:
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/timeout';
import { fileURLToPath } from 'url';
@Injectable()
export class AccessProviders {
// URL for backend API JSON
server: string = 'http://localhost/login-register-home/api';
constructor(public http: HttpClient){}
postData(body, file){
Let headers = new HttpHeaders({
'Content-Type' : 'application/json; charset=UTF-8'
});
Let options = {
headers: headers
}
return this.http.post(this.server + file, JSON.stringify(body), options)
.timeout(59000) // 59 sec timeout
.map(res => res);
}
}
Additional information:
- Angular CLI & Angular: 9.0.7
- Node: 12.16.1
- rxjs: 6.5.4
- typescript: 3.7.5
I would appreciate any help or guidance on resolving these issues. Thank you!