My goal is to get the metadata for all my Opportunities in Salesforce (the address, city, and state). I was told to look into query data directly from Apex, then I can return those values to my LWC. I'm not sure If I'm doing it right, but I created an apex file called QueryData.cls, with the code below; (following a YouTube video).
Apex "QueryData.cls" Code:
public with sharing class QueryData {
@AuraEnabled(cacheable=true)
public static List<Opportunity> getListofOpportunity() {
List<Opportunity> OppList = new List<Opportunity>();
OppList = [SELECT Id, Service_Adress__c FROM Opportunity LIMIT 5];
return OppList;
}
}
Refined Question:
Am I missing anything with my Apex code?
How would I be able to return my values to my LWC?
Anything else that I'm missing?
Contact
query to yourOpportunity
one.