function searchApiByFoodName() {
  // Get Food name from form
  userSearchedFood = $("#search-food-name").val();

  // Make Request
  $.ajax({
    type: "POST",
    url: "https://api.nal.usda.gov/fdc/v1/foods/search?api_key=DEMO_KEY",
    data: '{"query":"' + userSearchedFood + '", "pageSize": 10}',

    headers: {
      "Content-Type": "application/json",
    },
    dataType: "json",
    success: function (data) {
      console.log(data.foods)
      let listOfReformatedFoods = [];
      app.foundFoodList = updateFoodsFound(data.foods);
    },
    error: function (error) {
      console.log("ERROR");
    },
  });
}
// Searches the api by food name
Searches the api by food name
Searches the api by food name
function searchApiByFoodName() {
  userSearchedFood = $("#search-food-name").val();
  $.ajax({
    type: "POST",
    url: "https://api.nal.usda.gov/fdc/v1/foods/search?api_key=DEMO_KEY",
    data: '{"query":"' + userSearchedFood + '", "pageSize": 10}',
    headers: {
      "Content-Type": "application/json",
    },
    dataType: "json",
    success: function (data) {
      console.log(data.foods)
      let listOfReformatedFoods = [];
      app.foundFoodList = updateFoodsFound(data.foods);
    },
    error: function (error) {
      console.log("ERROR");
    },
  });
}
function searchApiByFoodName ( ) { userSearchedFood = $ ( "#search-food-name" ) . val ( ) ; $ . ajax ( { type : "POST" , url : "https://api.nal.usda.gov/fdc/v1/foods/search?api_key=DEMO_KEY" , data : '{"query":"' + userSearchedFood + '", "pageSize": 10}' , headers : { "Content-Type" : "application/json" , } , dataType : "json" , success : function ( data ) { console . log ( data . foods ) let listOfReformatedFoods = [ ] ; app . foundFoodList = updateFoodsFound ( data . foods ) ; } , error : function ( error ) { console . log ( "ERROR" ) ; } , } ) ; }
Searches the api by food name
Searches the api by food name
// Get Food name from form // Make Request