HTTP Post Request

Hy all, actually I am getting ’ post ’ of undefined error. see below:
And here is my code:

Please help.

In my project I solved in this way:

import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';

  selector: 'app-home',
  templateUrl: './'
export class HomePage implements OnInit {

  constructor(private http: HttpClient) { 

    let data = JSON.stringify({
      key: 'val',
      key2: ' otherVal'
    });'', data).subscribe((response) => {


On the server the Access-Control-Allow-Origin header must be set

1 Like

Thanks for replying, I was solved it with another way!