Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Demo of using @AuraEnabled without getter/setter in both Aura and LWC (SFSE: 292183)
<aura:application controller="q292183">
<aura:handler name="init" value="{!this}" action="{!c.init}" />
<aura:attribute name="data" type="Map" />
{!} {!} {!}
<hr />
<c:q292183lwc />
public class q292183 {
public class Response {
@AuraEnabled public String a, b, c;
@AuraEnabled(cacheable=true) public static Response getData() {
Response res = new Response();
res.a = 'Hello';
res.b = 'World';
res.c = 'Everyone';
return res;
init : function(component, event, helper) {
var action = component.get("c.getData");
response => component.set("", response.getReturnValue())
<template if:true={data}>
{data.a} {data.b} {data.c}
<template if:true={error}>
import { LightningElement, wire, track } from 'lwc';
import getData from '@salesforce/apex/Q292183.getData';
export default class Q292183lwc extends LightningElement {
@track data;
@track error;
@wire(getData, {})
result({data, error}) { = data;
this.error = error;
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="">

This comment has been minimized.

Copy link

@pchittum pchittum commented Feb 13, 2020

@brianmfear, mine is failing as an Apex type as an input parameter to an Apex method, not the return. But now that I'm saying that, I wonder how common is that really? Adding 2-3 params isn't a big deal. But you only get one object to pass back. So probably much more prevalent to pass back an Apex type than to use as input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.