dimanche 24 janvier 2021

From Angular via REST to web API and return

I have a .NET Core 5 web API with CORS and an Angular frontend.

The backend has a very simple REST API. You say https://localhost:44359/ping and the return is a "Pong".

At the frontend I have a button and a button-click event.

I can't find a understandable description how to send the REST request from the frontend starting by the button event to the backend and receiving and returning "Pong".

@Component({
  selector: 'app-click-me',
  template: `
    <button (click)="onClickMe()">Send Request!</button>
    `
})
export class ClickComponent {
  clickMessage = '';
  onClickMe() {
    this.clickMessage = https://localhost:44359/ping;
  }
  }
}



Aucun commentaire:

Enregistrer un commentaire