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
M ParnellM Parnell 

Create a server-side Apex controller class (Project - Quick Start: Lightning Components)

@AuraEnabled
public static List<Contact> getContacts() {
    return [Select Id, Name, Email, Title, Phone From Contact];
}
I'm receiving the following error: unexpected token: 'List'
 
Best Answer chosen by M Parnell
Mahesh DMahesh D
Hi

You can try below code but not sure exact reason.
@AuraEnabled
public static List<Contact> getContacts() { 
	List<Contact> conList = [Select Id, Name, Email, Title, Phone From Contact];
    return conList;
}

Regards,
Mahesh

All Answers

Mahesh DMahesh D
Hi

You can try below code but not sure exact reason.
@AuraEnabled
public static List<Contact> getContacts() { 
	List<Contact> conList = [Select Id, Name, Email, Title, Phone From Contact];
    return conList;
}

Regards,
Mahesh
This was selected as the best answer
M ParnellM Parnell
I received the same error message: unexpected token: 'List'User-added image

 
Mahesh DMahesh D
Please the full class here.
Sarah McDonaldSarah McDonald
Hey Gang,

What am I doing wrong here? I followed Mahesh's advice for M Parnell but to no avail.

User-added image

 
Alison TrottAlison Trott
I've tried both methods and keep getting the error:
Challenge Not yet complete... here's what's wrong: 
The client side JavaScript controller is not putting a server side action into the queue using $A.enqueueAction

Any ideas?
Kalue HerKalue Her
I was able to find the solution on another thread:

https://developer.salesforce.com/forums#!/feedtype=SINGLE_QUESTION_SEARCH_RESULT&id=906F0000000MLdgIAG

"you need to place that code inside the class"
Jess BurghJess Burgh
Hey all I just started this project and not surw what I'm doing wrong. User-added image <--- followe the first set of instructions

User-added image<--- followed the section set of structions


User-added image And got this error message. Any ideas? Thanks!!
Josh StigallJosh Stigall


Kalue's link is the key. Thanks!
Charlene ShihCharlene Shih
After copying and pasting the code, the format looked different. Does this matter to get the code to work?
Charles ThompsonCharles Thompson
@Charlene Shih - no, the formatting doesn't matter. 
I do have a habit of formatting everything after I copy & paste from Trailhead, though.  Just in case I need to go back to it later.