import { HttpClient } from '@angular/common/http';
import { inject, Injectable } from '@angular/core';
import { Book } from '../models/book';
import { Message } from '../models/message';

@Injectable({
  providedIn: 'root'
})
export class BookService {

  constructor() { }
  
    private httpClient = inject(HttpClient)
  
    getAll(){
      return this.httpClient.get<Book[]>("http://localhost:4000/books/getAll")
    }

    deleteBook(book: Book){
      return this.httpClient.post<Message>("http://localhost:4000/books/deleteBook",{name: book.name});
    }

    updateBook(name: string, pages: number){
      return this.httpClient.post<Message>("http://localhost:4000/books/updateBook",{name: name, pages: pages});
    }

}
