• Kenneth Chau
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

Hi,

I'm new to LWC and I'm trying to connect to apex class to get data from a custom object, and I got these error: Error during LWC component connect phase: [e[Nn] is not a function]

Here are my code:
NewApplication.js

import { LightningElement, api, wire } from 'lwc';
import getNewApplications from '@salesforce/apex/HelperNewApp.getNewApplications';

export default class NewApplication extends LightningElement {
    //@wire (getApplicationStatus) appStatus;
    @api newApps;
    @api error;

    @wire (getNewApplications, {status: "New"}) 
    wiredNewApplications(data,error){
        if (data) {
            this.newApps = data;
            // eslint-disable-next-line no-console
            console.log('DATA => ', data, JSON.stringify(data));
        } else if (error) {
            this.error = error;
            console.log('ERRor => ', error, JSON.stringify(error));
        }
    };

    
   
}

NewApplication.html
<template>
    <div class="container">
        <h1>New Agent Applications</h1>

        <div>
            <template if:true = {newApps}>
                
                <template for:each={newApps} for:item="app">
                    {app.Name}                    
                </template>
            </template>
            <template if:true = {error}>
                Error: {error}
            </template>
        </div>

    </div>
</template>

HelperNewApp.cls
public with sharing class HelperNewApp {
    @AuraEnabled(cacheable=true)
    public static List<Agent_Application__c> getNewApplications(String status) {

        return [SELECT Id, Name, Primary_Contact_Name__c,
                    Company_Name__c, Status__c, CreatedDate
                        FROM Agent_Application__c
            WHERE Status__c = :status
            ORDER BY CreatedDate];
    }
}


Thanks,