function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kenneth ChauKenneth Chau 

LWC: Error during LWC component connect phase

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,
SwethaSwetha (Salesforce Developers) 
HI Kenneth,
Based on similar reported issues this error is seen when you are trying to return an Object and you are trying to iterate over it.

See https://salesforce.stackexchange.com/questions/326936/uncaught-in-promise-typeerror-eeo-is-not-a-function-error-in-lwc

https://salesforce.stackexchange.com/questions/281599/uncaught-in-promise-typeerror-tyn-is-not-a-function-in-lwc

If this information helps, please mark the answer as best. Thank you
Alain CabonAlain Cabon

https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.apex_wire_method

wiredContacts( { error, data  } ) {   with brackets  so  wiredNewApplications(  { error, data  } ){
@wire(getContactList)
    wiredContacts({ error, data }) {
        if (data) {
            this.contacts = data;
            this.error = undefined;
        } else if (error) {
            this.error = error;
            this.contacts = undefined;
        }
    }


 
mukesh guptamukesh gupta
Hi Kenneth,

Please use below code:-
 
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));
        }
    };

    
   
}

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh