#Why is there no function keywords in these functions ?

1 messages · Page 1 of 1 (latest)

misty socket
#
mport { Injectable } from '@angular/core';
import {HttpClient} from '@angular/common/http';

@Injectable()
export class UsersService {
  apiURL = "https://api.github.com/users";
  

  constructor(private http: HttpClient) { }

// Get all users
 getAllUsers() { 
   return this.http.get(`${this.apiURL}?/per_page=10`);
}

// Get single user
getSingleUser(username: string) {
  return this.http.get(`${this.apiURL}/${username}`);
}


 }

Can someone please explain why these functions are not defined as
function getAllUsers(){
}

dense pelican
#

Because they are methods of a class, not standalone functions.

misty socket
#

Oh