While working with @wire, I figured out that the data returned from the apex method is not available to use on component load. However, after load, when I I called a method(triggered through event), the data from apex method became accessable.
@wire (getCurrencySymbol)
objCurrency({data,error}){
if(data)
this.sCurrency = data;
else
this.sCurrencyError = error;
}
get currencySymbol(){
// eslint-disable-next-line no-console
console.log('this.sCurrency get : ',this.sCurrency);
return this.sCurrency;
}
The data is not accessible inside js using any of the lifecycle hooks.
What I want here is to use this.sCurrency
which should hold returned data inside another method which is called from connectedcallback and do some processing.
Also, if I use {currencySymbol} on html, it displays the value returned from apex method but is still not accessible inside the other method(which I haven't added in the below code snipper).
Any idea how this can be accomplished?
connectedCallback
, even if the result is currently cached. Instead, you'll need to perform any work you need to do in either a setter, or in the callback for the wired method. The bit you've omitted is probably more important than you realize. – sfdcfox Sep 6 '19 at 3:58