Skip to main content

Maybe I just need a second set of eyes to look at this but, after I copied the JavaScript code into the housingmap.js file it throws a syntax error...it's copied directly from the Trail example so I must be missing something simple that I just don't see.  Any help is much appreciated!  Also, the snapshot does not show all the code below the error...just FYI

Copied housingmap.js code throwing syntax error?

 

#Trailhead Challenges

2 risposte
  1. 16 ago 2024, 21:11

    Hi @James (Jim) Kepler ,

     

    Try this

     

    import { LightningElement, wire } from "lwc";

    import getHouses from "@salesforce/apex/HouseService.getRecords";

    export default class HousingMap extends LightningElement {

    mapMarkers;

    error;

    @wire(getHouses)

    wiredHouses({ error, data }) {

    if (data) {

    // Use JavaScript Map function to transform the Apex method response wired to the component into the format required by lightning-map

    this.mapMarkers = data.map((element) => {

    return {

    location: {

    Street: element.Address__c,

    City: element.City__c,

    State: element.State__c

    },

    title: element.Name

    };

    });

    this.error = undefined;

    } else if (error) {

    this.error = error;

    this.mapMarkers = undefined;

    }

    }

    https://trailhead.salesforce.com/content/learn/projects/get-started-with-salesforce-development/build-reusable-ui-component-with-lightning-web-components

0/9000