0
 return this.http.post(this.config.apiUrl, user).subscribe(x=>x);

Is this arrow function but arrow function is supposed to be like this ()=>

export class ApiService {
  config = new Configuration();
  constructor(private http: HttpClient) { }
  registerUser(user: any) { 
   return this.http.post(this.config.apiUrl, user).subscribe(x=>x);
  }
guhawaf
  • 61
  • 1
  • 7

2 Answers2

0

()=> is non-parameterized arrow function

x => x is equivalent to (x) => x which takes x as parameter and then returns x as result


Btw, subscription does not return value instead Subscription. When you subscribe you generally need to assign it to another variable or use it inside that subscription.

Derviş Kayımbaşıoğlu
  • 28,492
  • 4
  • 50
  • 72
0
 return this.http.post(this.config.apiUrl, user).subscribe(x=>x);

Here Subscribe function is to get the response back from the API to the calling function. (X => x).

'x' is the response from the API.(Lets say success or failure)

and you are mapping that to 'X'. (you can console it with the help of X )

Raahul
  • 399
  • 1
  • 3
  • 11