L_Angeli

MealsRetriever

Apr 8th, 2021
373
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public with sharing class MealsRetriever {
  2.     private static final String MEAL_URL = 'https://www.themealdb.com/api/json/v1/1/search.php?s=';
  3.     private static final String GET = 'GET';
  4.  
  5.     public static List<Meals> getMealData(){
  6.  
  7.         List<Meals> mealData = new List<Meals>();
  8.  
  9.         Http httpCallout = new Http();
  10.         HttpRequest req = new HttpRequest();
  11.         req.setEndpoint(MEAL_URL);
  12.         req.setMethod(GET);
  13.  
  14.         HttpResponse mealResponse = httpCallout.send(req);
  15.         Meals mealParseResponse = Meals.parse(mealResponse.getBody());
  16.         List<Meals> retrievedMeals = mealParseResponse.meals;
  17.  
  18.         /*PARTE COM ERRO
  19.         for(Meals m: retrievedMeals){
  20.             mealData.add(m.meals);
  21.         }
  22. */
  23.  
  24.         return mealData;
  25.         }
  26.     }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×