forcedotcom / lwc-dev-server-feedback

LWC Local Development
BSD 3-Clause "New" or "Revised" License
45 stars 10 forks source link

Wire not working #46

Closed juvian closed 4 years ago

juvian commented 4 years ago

Component:

 import getListingTypesBySite from '@salesforce/apex/List_BuyBox_Item.getListingTypesBySite';
    @wire(getListingTypesBySite, {})
    listingTypeInfo({data, error}) {
        if (data) this.listing_types = data;
    }

Apex:

public class List_BuyBox_Item {
    @AuraEnabled(cacheable=true)
    public static Map<String, Map<String, String>> getListingTypesBySite() {
         Map<String, Map<String, String>> listingTypes = new Map<String, Map<String, String>>();

         for (Listing_Type__c listing : [SELECT 
                                                        Name__c,
                                                        ML_ID__c,
                                                        Site_Id__c 
                                                FROM
                                                        Listing_Type__c
                                                WHERE
                                                        Inactive__c = False
                                                ]) {
             if (listingTypes.containsKey(listing.site_id__c) == false) listingTypes.put(listing.site_id__c, new Map<String, String>());
             listingTypes.get(listing.site_id__c).put(listing.ml_id__c, listing.name__c);
         }

         return listingTypes;
    }
}

Response from http://localhost:3333/api/apex/execute: 500 internal error -> error parsing or finding aura config: window.Aura not found

Does wire not work from local development?

KrisGraySFDC commented 4 years ago

Wire is intended to work. Can you include some information here for us?

Thanks

juvian commented 4 years ago

It is not a pre-release org, but it is not a scratch org either. Lightning is not yet enabled and I'm using components inside visualforce with lightning out. I can see that in the visualforce, after including the lightning out.js script there is a window.Aura property, but in the local environment there is not.

I can test on monday if it works fine in the visualforce, if it doesn't work either I guess auraenabled methods might not work with lightning out.

KrisGraySFDC commented 4 years ago

That explains it. If Lightning isn't enabled, we won't be able to make requests via Apex. Thats not a requirement of the framework, just a limitation of the LWC Local Dev Beta implementation.

KrisGraySFDC commented 4 years ago

Also, because data modifications will happen against the org you're connected to, we encourage you not to use real orgs to test against.

juvian commented 4 years ago

I see, good to know. Will try enabling lightning then. And yeah, its a development org. Thanks!

KrisGraySFDC commented 4 years ago

You're welcome.