function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Amy S. OplingerAmy S. Oplinger 

Create Server-side Apex Controller Class - ERROR please help!

Trying to verify the first step of 
Quick Start: Lightning ComponentsCreate a Server-side Apex Controller Class and get the following error: Please advise. Thanks!



User-added image
Abhishek_DEOAbhishek_DEO
Actually, you need to place that code inside the class. 
For eg. 
 
public with sharing class MyContactListController{
     
    @AuraEnabled 
    public static List<contact> getContacts() {

        // Perform isAccessible() checks here 
        return [SELECT Id, Name  FROM contact];
    }
}

Please try to save above class and mark this as answer if it helps you.
Terimarie DegreeTerimarie Degree
thanks, i was making the same mistake!
Gary O'NeillGary O'Neill
Same, thanks! Stupid mistake, but easy to do when you think, "Eh just copy paste this in".
Segvan JohnsonSegvan Johnson
here is a full correct code,
public class MyContactListController {
    
    @AuraEnabled
public static List<Contact> getContacts(Id recordId) {
   return [Select Id, FirstName, LastName, Email, Phone From Contact Where AccountId = :recordId];
}


}