import axios from 'axios';

const apiKey = 'KKw8ffPvdVzSenGfPq7BdBi9SlwohNzj4PAtl3uT';
const searchURL = 'https://api.nal.usda.gov/ndb/search/';

const params = {
  format: 'json',
  sort: 'n',
  max: 25,
  offset: 0,
  api_key: apiKey
};

export const searchFoodDescription = (query) => {
  return axios.get(searchURL, {
    params: {
      ...params,
      q: query
    }
  })
  .then(response => response.data.list.item)
  .catch(error => console.log(error));

};

const searchNutrientInfo = (foodKey) => {

};

@@ -80,16 +80,69 @@
 tl3uT';%0A
+%0Aexport const searchFoodDescription = (query) =%3E %7B%0A  
 const se
@@ -188,24 +188,26 @@
 /search/';%0A%0A
+  
 const params
@@ -211,16 +211,18 @@
 ams = %7B%0A
+  
   format
@@ -231,16 +231,18 @@
 'json',%0A
+  
   sort: 
@@ -242,20 +242,22 @@
  sort: '
-n
+r
 ',%0A
+  
   max: 2
@@ -259,16 +259,18 @@
 ax: 25,%0A
+  
   offset
@@ -274,16 +274,18 @@
 set: 0,%0A
+  
   api_ke
@@ -298,61 +298,12 @@
 Key%0A
+  
 %7D;
-%0A%0Aexport const searchFoodDescription = (query) =%3E %7B
 %0A  r
@@ -477,16 +477,23 @@
 );%0A%0A%7D;%0A%0A
+export 
 const se
@@ -526,12 +526,1007 @@
 y) =%3E %7B%0A
+  const nutrients = %5B%0A    '208', // kcal%0A    '203', // protein%0A    '204', // fat%0A    '205', // carbohydrate%0A    '328', // vitamin D%0A    '418', // vitamin B12%0A    '301', // calcium%0A    '303', // iron%0A    '309', // zinc%0A    '629', // omega-3 EPA%0A    '851', // omega-3 ALA%0A    '621', // omega-3 DHA (unfortunately unavailable as one)%0A  %5D;%0A  const searchURL = 'https://api.nal.usda.gov/ndb/nutrients/?'%0A    + 'api_key='    + apiKey%0A    + '&nutrients=' + nutrients%5B0%5D%0A    + '&nutrients=' + nutrients%5B1%5D%0A    + '&nutrients=' + nutrients%5B2%5D%0A    + '&nutrients=' + nutrients%5B3%5D%0A    + '&nutrients=' + nutrients%5B4%5D%0A    + '&nutrients=' + nutrients%5B5%5D%0A    + '&nutrients=' + nutrients%5B6%5D%0A    + '&nutrients=' + nutrients%5B7%5D%0A    + '&nutrients=' + nutrients%5B8%5D%0A    + '&nutrients=' + nutrients%5B9%5D%0A    + '&nutrients=' + nutrients%5B10%5D%0A    + '&nutrients=' + nutrients%5B11%5D%0A    + '&ndbno=' + foodKey%0A  return axios.get(searchURL)%0A  .then(response =%3E response.data.report.foods%5B0%5D)%0A  .catch(error =%3E console.log(error));
 %0A%7D;%0A

Add api for calling usda database.