import { Component, OnInit } from '@angular/core';
import { AnimeService} from '../shared/services/anime.service'
import { HttpClient } from '@angular/common/http';


@Component({
  selector: 'app-addanime',
  templateUrl: './addanime.component.html',
  styleUrls: ['./addanime.component.css']
})
export class AddanimeComponent implements OnInit {

  name: string | undefined;
  result: string | undefined;
  

  constructor(private animeService: AnimeService ,private http: HttpClient ) { }
  ngOnInit(): void {
    throw new Error('Method not implemented.');
  }

  insert() {

    let url = "http://localhost:4040/api/anime/add"
    this.http.post(url, {
      name:this.name
    }).toPromise().then((data: any) => {
      console.log(data)
      console.log(JSON.stringify(data.json.name))
      this.result = JSON.stringify(data.json.name)
    })
  }



}
