Search code examples
salesforceapexlwcaura-framework

LWC superbadge step 14 challenge


I am on step 14 of LWC superbadge and getting the following error : We can't find the wire service provisioned function similarBoats() with the data property used correctly in the component similarBoats JavaScript file. Make sure the component was created according to the requirements, including the proper values for relatedBoats, boatId, and similarBy, using the proper case-sensitivity and consistent quotation. Below is the JS code for my file. Can someone tell me what is wrong in my code?? I have been stuck on this for more than 24 hours now.

    import { LightningElement, api, wire } from 'lwc';
import getSimilarBoats from '@salesforce/apex/BoatDataService.getSimilarBoats';
import { NavigationMixin } from 'lightning/navigation'
export default class SimilarBoats extends NavigationMixin(LightningElement) {

    @api similarBy;
    relatedBoats;
    boatId;
    error;

    // public
    @api
    get recordId() {
        return this.boatId;
    }
    set recordId(value) {
        // sets the boatId value
        this.boatId = value;
        // sets the boatId attribute
    }

    @wire(getSimilarBoats, { boatId: this.boatId, similarBy: '$similarBy' })
    similarBoats({ error, data }) {
        if (data) {
            this.relatedBoats = data;
            this.error = undefined;
        } else if (error) {
            this.relatedBoats = undefined;
            this.error = error;
        }
    }
    get getTitle() {
        return 'Similar boats by ' + this.similarBy;
    }
    get noBoats() {
        return !(this.relatedBoats && this.relatedBoats.length > 0);
    }

    // Navigate to record page
    openBoatDetailPage(event) {
        this[NavigationMixin.Navigate]({
            type: 'standard__recordPage',
            attributes: {
                recordId: this.boatId,
                objectApiName: BOAT_OBJECT,
                actionName: 'view'
            },
        });
    }

}

Solution

  • Your problem is that you're using { boatId: this.boatId, ... , when you need to use { boatId: '$boatId', ....