Encountering an issue while utilizing Angular 5 Services, looking for assistance in identifying what's wrong with the code below
Referenced various questions but none provided a solution
- Question 1
- Question 2
- Question 3
The aim is to initialize a value within the class and utilize it in a method
Even though the url value is defined in the class, encountering an error
Cannot read property 'url' of undefined
at console.log(this.url);
@Injectable()
export class OwnService {
public accessTokenvalue = '';
public url = 'https://www.someurl.com/id=';
constructor(private hp: HelpService) {
}
public gethpPhotos() {
this.hp.login()
.then(function (response: LoginResponse) {
console.log(response);
console.log(this.url);
})
.catch((error: any) => console.error(error));
}
}