// meal.service.ts
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';

const API_URL = 'https://www.themealdb.com/api/json/v1/1';

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

  constructor(private http: HttpClient) {}

  // 根据食物名称查询菜谱和食物详细信息
  searchMealsByName(mealName: string): Observable<any> {
    const url = `${API_URL}/search.php?s=${mealName}`;
    return this.http.get<any>(url);
  }
}
