+ Start a Discussion
Medhanie Habte 37Medhanie Habte 37 

Lightning Component Superbadg - Issue with Step 3

Greetings all, I am working my way up to step 3 on the lightning component superbadge and seem to be on the BoatSeachResults apex class.

I am encountering this message, although my class is written as shown below.

Challenge Not yet complete... here's what's wrong: 
We couldn't find a
getBoats() method with the boatTypeId parameter in the BoatSearchResults Apex controller. Make sure the getBoats() method uses the string data type so that you can pass empty values to it.
 
public with sharing class BoatSearchResults {
    @AuraEnabled
    public static String getBoats(Id boatTypeId) {
        BoatType__c boat = [SELECT Id FROM BoatType__c WHERE Id = :boatTypeId];
        return string.valueOf(boat); 
    }
}

 
Best Answer chosen by Medhanie Habte 37
Medhanie Habte 37Medhanie Habte 37
Problem Solved. I was querying the wrong object. I should have been querying boats instead, luckily that helped me pass.
 
public with sharing class BoatSearchResults  {
    @AuraEnabled
    public static List<Boat__c> getBoats(String boatTypeId) {
      if(boatTypeId != '')  {
             return [SELECT id, BoatType__c, picture__c, name,contact__r.Name
                    FROM Boat__c
                    WHERE BoatType__c =:boatTypeId];
      } else {
          return [SELECT id, BoatType__c, picture__c, name,contact__r.Name
                    FROM Boat__c];
      }
         }
         }