refreshApex in lwc doesn’t seem to work

I have a custom lwc that works with refresh apex. I want a method to be refreshed from another function


import {refreshApex} from '@salesforce/apex';
import initData from '@salesforce/apex/myClass.initData';

export default class Tm_GDPRInfoSignatureLWC LightningElement {

    @track myData;

    @wire(initData , {recordId : '$recordID'}) wiredInitData(result) {
        this.wiredGDPRresult = result;
        //data retrieved
        if( {
            this.myData =;
        else if(result.error){

        return refreshApex(this.wiredGDPRresult);

And it’s working find when initializing the lwc but whenever I call refreshData it’s doing nothing (not even displaying console.logs())

Is there something I’m setting wrong or do I need to call refreshApex in a different way?


I’m calling my function whenever I receive a custom event from another lwc. And it’s receiving that event but refreshApex doesn’t do anything

    registerListener('refreshData', this.refreshData, this);


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

It will actually work but as its cacheable (or cached to be precise) apex method, the wired function imperativeWire will be invoked ONLY if the apex method response changes/modified. However every time you invoke refreshData, you will see the apex log – can be tested in developer console.

For testing, you can return some accounts:

public static List<Account> getAccountsList() {
    return [SELECT Id, Name, Phone FROM Account LIMIT 10];

Then use wired function to get these accounts in LWC component.

Then when you change some field value in one of these accounts and invoke refreshData you will see the console log in LWC also.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x