MyOpportunities.js
import { LightningElement, api, wire } from 'lwc';
import getOpportunities from '@salesforce/apex/OpportunityController.findMyOpportunities';
export default class MyOpportunities extends LightningElement {
@api userId;
@wire(getOpportunities, { oppOwner: '$userId' })
opportunities;
}
OpportunityController.cls
public with sharing class OpportunityController {
@AuraEnabled
public static List<Opportunity> findMyOpportunities(Id oppOwner) {
return [
SELECT Id, Name, StageName, Amount
FROM Opportunity
WHERE OwnerId = :oppOwner
];
}
}
A developer is experiencing issues with a Lightning web component. The component must surface information about Opportunities owned by the currently logged-in user. When the component is rendered, the following message is displayed:
"Error retrieving data".
Which action must be completed in the Apex method to make it wireable?