0

I am getting below error when i try to pass data to apex. I did everything to debug but unable to find root cause.

 aura_prod.js:3 Uncaught (in promise) TypeError: Cannot read property 'Symbol(ViewModel)' of undefined
    at vt (aura_prod.js:3)
    at Object.Ke [as update] (aura_prod.js:3)
    at aura_prod.js:3
    at Object.update (aura_prod.js:3)
    at En (aura_prod.js:3)
    at kn (aura_prod.js:3)
    at aura_prod.js:3
    at yr (aura_prod.js:3)
    at $n (aura_prod.js:3)
    at Object.update (aura_prod.js:3)

Below is the apex call from JS

updatedata({
        Update: JSON.stringify(records),
        currenyRecord: JSON.stringify(currentRecords)
    })
        .then(result => {

            this.isOpenModal = true;
            this.isPriceSection=true;
            this.priceChange = JSON.stringify(result);

            this.isLoaded = true;
        })
        .catch((error) => {


            const evt = new ShowToastEvent({
                title: 'Oops! Something went wrong',
                message: error,
                variant: 'error'
            });
            this.dispatchEvent(evt);
            this.isLoaded = false;
        });

EDIT 1

Markup example

    <template if:true={isOpenModal}>
     <div>

    <template if:true={isPriceSection}>

<c-page-section change={priceChange} </c-page-section>
    </template>

    </div>
    </template>

Apex Method simply returns string

also, I am able to pass data correctly to apex and getting expected response too.

BUT, Real issue is, when i hit on save button 'updatedata' will get called, before calling the method i get this error 'Uncaught {in promise}' later my execution goes to .Then(). Can someone please help me understand why i get Uncaught initially and later .Then() gets executed.

I am unable to share the apex method as it is bit complex but only thing i am sure is apex is returning data as expected.

6
  • Can you add markup too? Feb 7, 2020 at 19:24
  • The markup for the component, and the Apex method being called, would both be useful here. You can edit your question to include more information.
    – sfdcfox
    Feb 7, 2020 at 19:26
  • @sfdcfox pranay-jaiswal have added description. Thanks in advance.
    – rahulsfdx
    Feb 7, 2020 at 20:00
  • i am not sure but i found this reference. Is it related to chaining the promise. stackoverflow.com/questions/42460039/…
    – rahulsfdx
    Feb 7, 2020 at 20:01
  • @rahulsfdx wrap your updatedata method in try-catch which will show you where the error is coming from. Mar 6 at 6:25

1 Answer 1

1

I got the isssue, "Uncaught (in promise) TypeError: Cannot read property 'Symbol(ViewModel)' of undefined" being thrown as my Iterator was accessing same key when i was rendering data.

Please follow below steps to resolve the issue ---

  1. Enable the debug mode which will give you detailed error message and quit understandable when we look at it.

it’s a best practice to develop your Lightning web components in an org using debug mode. That way you see if your code can be even more improved while you develop.

There’s one caveat at the time of this writing: you’ll likely see other console warnings from the LWC engine on the console, as we with the initial release don’t filter on your own namespace. Because of that, you see other warnings for things like base Lightning components.

Refer steps mentioned in article which will help you resolve the issue.

https://developer.salesforce.com/blogs/2019/02/debug-your-lightning-web-components.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .