LWC component not renderingFIELD_INTEGRITY_EXCEPTION Invalid attributGetting data from Lightning componentHow to use JsForce in a Salesforce Lightning ComponentIs there a way to load every label data and every SObject description data in Lightning Web Component using only Javascript without any Apex?LWC : passing parameter to getrecordlwc data-table not renderingDoes LWC @wire works with custom classes?A @track decorator can only be applied to a public fieldRenaming LWC const variable breaks component behaviorApex method not getting invoked in LWC

How to get maximum number that newcount can hold?

"Fewer errors means better products" or "Fewer errors mean better products"?

Is verification of a blockchain computationally cheaper than recreating it?

What is time? Does it flow linearly? If so, how are we sure?

Is Illustrator accurate for business card sizes?

Will medical institutions reject an applicant based on being 28 years of age?

"Will flex for food". What does this phrase mean?

linearization of objective function

Can I shorten this filter, that finds disk sizes over 100G?

Can birds evolve without trees?

Need help identifying how to open this bolt/screw

Do the rules for the "Buying a Magic Item" downtime activity allow a character an opportunity to purchase the item later?

Does the use of a new concept require a prior definition?

Backpacking with incontinence

Reasons for using monsters as bioweapons

Does the problem of P vs NP come under the category of Operational Research?

Word for pulling a punch in karate

How were x-ray diffraction patterns deciphered before computers?

What is the difference between 2/4 and 4/4 when it comes the accented beats?

Being told my "network" isn't PCI compliant. I don't even have a server! Do I have to comply?

Overprovisioning SSD on ubuntu. How? Ubuntu 19.04 Samsung SSD 860

HackerRank Implement Queue using two stacks Solution

Why do we need a voltage divider when we get the same voltage at the output as the input?

How to power down external drive safely



LWC component not rendering


FIELD_INTEGRITY_EXCEPTION Invalid attributGetting data from Lightning componentHow to use JsForce in a Salesforce Lightning ComponentIs there a way to load every label data and every SObject description data in Lightning Web Component using only Javascript without any Apex?LWC : passing parameter to getrecordlwc data-table not renderingDoes LWC @wire works with custom classes?A @track decorator can only be applied to a public fieldRenaming LWC const variable breaks component behaviorApex method not getting invoked in LWC






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I have a lightning web component that wires an apex method that calls out to JSONplaceholder.com to get back some data. I'm having issue with the whole component rendering at all. While in community builder (component lives in a community) I occasionally get an error saying



"This page has an error. You might just need to refresh it. Failed to initialize a component [postId is not defined] Callback failed: serviceComponent://ui.comm.runtime.components.aura.components.siteforce.controller.PubliclyCacheableComponentLoaderController/ACTION$getPageComponent Failing descriptor: siteforce-generatedpage-143e6e1e-5839-4709-8899-f2536a9ff760.c1564858326133".



I've confirmed the apex works by running it in the dev console.



Here is the code:



Apex



public without sharing class postController 

@AuraEnabled(cacheable=true)
public static String getPosts(Integer postId)
Http http = new Http();
HttpRequest req = new HttpRequest();

string resource = 'https://jsonplaceholder.typicode.com/comments?postId=' + postId;

req.setEndpoint(resource);
req.setMethod('GET');

HttpResponse res = http.send(req);
String jsonData = res.getBody();
system.debug(jsonData);
return jsonData;




JS



import LightningElement, track, wire from 'lwc';
import getPosts from '@salesforce/apex/postController.getPosts';

export default class PracticePosts extends LightningElement

@track postInfo = [];
@track postId = 1;
@track error;

@wire(getPosts, postId: `$postId`)
getJSON(error, data)
if (data)
this.postInfo = JSON.parse(data);
else if (error)
this.error = error;





HTML



<template>
<lightning-card title="Posts" icon-name="custom:custom67">
<div class="slds-m-horizontal-medium">
<template if:true=postInfo.data>
<p>My dataaaaaaa</p>
<ul>
<li for:each=postInfo.data for:item="post" key=post.id>post.name</li>
</ul>
</template>
<template if:true=postInfo.error>
<p>Dang</p>
<p>postInfo.error</p>
</template>
</div>
</lightning-card>
</template>









share|improve this question
































    2















    I have a lightning web component that wires an apex method that calls out to JSONplaceholder.com to get back some data. I'm having issue with the whole component rendering at all. While in community builder (component lives in a community) I occasionally get an error saying



    "This page has an error. You might just need to refresh it. Failed to initialize a component [postId is not defined] Callback failed: serviceComponent://ui.comm.runtime.components.aura.components.siteforce.controller.PubliclyCacheableComponentLoaderController/ACTION$getPageComponent Failing descriptor: siteforce-generatedpage-143e6e1e-5839-4709-8899-f2536a9ff760.c1564858326133".



    I've confirmed the apex works by running it in the dev console.



    Here is the code:



    Apex



    public without sharing class postController 

    @AuraEnabled(cacheable=true)
    public static String getPosts(Integer postId)
    Http http = new Http();
    HttpRequest req = new HttpRequest();

    string resource = 'https://jsonplaceholder.typicode.com/comments?postId=' + postId;

    req.setEndpoint(resource);
    req.setMethod('GET');

    HttpResponse res = http.send(req);
    String jsonData = res.getBody();
    system.debug(jsonData);
    return jsonData;




    JS



    import LightningElement, track, wire from 'lwc';
    import getPosts from '@salesforce/apex/postController.getPosts';

    export default class PracticePosts extends LightningElement

    @track postInfo = [];
    @track postId = 1;
    @track error;

    @wire(getPosts, postId: `$postId`)
    getJSON(error, data)
    if (data)
    this.postInfo = JSON.parse(data);
    else if (error)
    this.error = error;





    HTML



    <template>
    <lightning-card title="Posts" icon-name="custom:custom67">
    <div class="slds-m-horizontal-medium">
    <template if:true=postInfo.data>
    <p>My dataaaaaaa</p>
    <ul>
    <li for:each=postInfo.data for:item="post" key=post.id>post.name</li>
    </ul>
    </template>
    <template if:true=postInfo.error>
    <p>Dang</p>
    <p>postInfo.error</p>
    </template>
    </div>
    </lightning-card>
    </template>









    share|improve this question




























      2












      2








      2








      I have a lightning web component that wires an apex method that calls out to JSONplaceholder.com to get back some data. I'm having issue with the whole component rendering at all. While in community builder (component lives in a community) I occasionally get an error saying



      "This page has an error. You might just need to refresh it. Failed to initialize a component [postId is not defined] Callback failed: serviceComponent://ui.comm.runtime.components.aura.components.siteforce.controller.PubliclyCacheableComponentLoaderController/ACTION$getPageComponent Failing descriptor: siteforce-generatedpage-143e6e1e-5839-4709-8899-f2536a9ff760.c1564858326133".



      I've confirmed the apex works by running it in the dev console.



      Here is the code:



      Apex



      public without sharing class postController 

      @AuraEnabled(cacheable=true)
      public static String getPosts(Integer postId)
      Http http = new Http();
      HttpRequest req = new HttpRequest();

      string resource = 'https://jsonplaceholder.typicode.com/comments?postId=' + postId;

      req.setEndpoint(resource);
      req.setMethod('GET');

      HttpResponse res = http.send(req);
      String jsonData = res.getBody();
      system.debug(jsonData);
      return jsonData;




      JS



      import LightningElement, track, wire from 'lwc';
      import getPosts from '@salesforce/apex/postController.getPosts';

      export default class PracticePosts extends LightningElement

      @track postInfo = [];
      @track postId = 1;
      @track error;

      @wire(getPosts, postId: `$postId`)
      getJSON(error, data)
      if (data)
      this.postInfo = JSON.parse(data);
      else if (error)
      this.error = error;





      HTML



      <template>
      <lightning-card title="Posts" icon-name="custom:custom67">
      <div class="slds-m-horizontal-medium">
      <template if:true=postInfo.data>
      <p>My dataaaaaaa</p>
      <ul>
      <li for:each=postInfo.data for:item="post" key=post.id>post.name</li>
      </ul>
      </template>
      <template if:true=postInfo.error>
      <p>Dang</p>
      <p>postInfo.error</p>
      </template>
      </div>
      </lightning-card>
      </template>









      share|improve this question
















      I have a lightning web component that wires an apex method that calls out to JSONplaceholder.com to get back some data. I'm having issue with the whole component rendering at all. While in community builder (component lives in a community) I occasionally get an error saying



      "This page has an error. You might just need to refresh it. Failed to initialize a component [postId is not defined] Callback failed: serviceComponent://ui.comm.runtime.components.aura.components.siteforce.controller.PubliclyCacheableComponentLoaderController/ACTION$getPageComponent Failing descriptor: siteforce-generatedpage-143e6e1e-5839-4709-8899-f2536a9ff760.c1564858326133".



      I've confirmed the apex works by running it in the dev console.



      Here is the code:



      Apex



      public without sharing class postController 

      @AuraEnabled(cacheable=true)
      public static String getPosts(Integer postId)
      Http http = new Http();
      HttpRequest req = new HttpRequest();

      string resource = 'https://jsonplaceholder.typicode.com/comments?postId=' + postId;

      req.setEndpoint(resource);
      req.setMethod('GET');

      HttpResponse res = http.send(req);
      String jsonData = res.getBody();
      system.debug(jsonData);
      return jsonData;




      JS



      import LightningElement, track, wire from 'lwc';
      import getPosts from '@salesforce/apex/postController.getPosts';

      export default class PracticePosts extends LightningElement

      @track postInfo = [];
      @track postId = 1;
      @track error;

      @wire(getPosts, postId: `$postId`)
      getJSON(error, data)
      if (data)
      this.postInfo = JSON.parse(data);
      else if (error)
      this.error = error;





      HTML



      <template>
      <lightning-card title="Posts" icon-name="custom:custom67">
      <div class="slds-m-horizontal-medium">
      <template if:true=postInfo.data>
      <p>My dataaaaaaa</p>
      <ul>
      <li for:each=postInfo.data for:item="post" key=post.id>post.name</li>
      </ul>
      </template>
      <template if:true=postInfo.error>
      <p>Dang</p>
      <p>postInfo.error</p>
      </template>
      </div>
      </lightning-card>
      </template>






      apex javascript lightning-web-components lwc-wire-adapter






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 7 hours ago







      boogie man

















      asked 8 hours ago









      boogie manboogie man

      254 bronze badges




      254 bronze badges























          1 Answer
          1






          active

          oldest

          votes


















          2














          There are some fundamental issues with the code.



          The return type is a string as per your backend apex class and hence first thing is to parse the response into Javascript object .In your case the API is returning an Array and hence you will need an Array variable .



          Here is how the correct JS code looks like



          import LightningElement, track, wire from 'lwc';
          import getPosts from '@salesforce/apex/postController.getPosts';


          export default class JsonTest extends LightningElement

          @track postInfo = [];
          @track postId = 1;
          @track error;

          @wire(getPosts, postId: '$postId')
          getJSON(error, data)
          if (data)
          this.postInfo = JSON.parse(data);
          else if (error)
          this.error = error;





          The HTML template file is as below



          <template>
          <lightning-card title="Posts" icon-name="custom:custom67">
          <div class="slds-m-horizontal-medium">
          <template if:true=postInfo>
          <p>My dataaaaaaa</p>
          <ul>
          <li for:each=postInfo for:item="post" key=post.id>post.name</li>
          </ul>
          </template>
          <template if:true=postInfo.error>
          <p>Dang</p>
          <p>postInfo.error</p>
          </template>
          </div>
          </lightning-card>
          </template>





          share|improve this answer




















          • 1





            Please update your question with latest code in your org

            – Mohith Shrivastava
            7 hours ago






          • 1





            Also note I changed variable names as well in my answer .You had same variables for your wire and track properties which could also be tht cause of the issue

            – Mohith Shrivastava
            7 hours ago






          • 1





            Check my front end code .I have changed that as well .You should use right properties

            – Mohith Shrivastava
            6 hours ago






          • 1





            I was able to get it working in my org fine

            – Mohith Shrivastava
            6 hours ago






          • 1





            On the front end you have postInfo.data , it should be postInfo.

            – Mohith Shrivastava
            6 hours ago













          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "459"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f272242%2flwc-component-not-rendering%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          There are some fundamental issues with the code.



          The return type is a string as per your backend apex class and hence first thing is to parse the response into Javascript object .In your case the API is returning an Array and hence you will need an Array variable .



          Here is how the correct JS code looks like



          import LightningElement, track, wire from 'lwc';
          import getPosts from '@salesforce/apex/postController.getPosts';


          export default class JsonTest extends LightningElement

          @track postInfo = [];
          @track postId = 1;
          @track error;

          @wire(getPosts, postId: '$postId')
          getJSON(error, data)
          if (data)
          this.postInfo = JSON.parse(data);
          else if (error)
          this.error = error;





          The HTML template file is as below



          <template>
          <lightning-card title="Posts" icon-name="custom:custom67">
          <div class="slds-m-horizontal-medium">
          <template if:true=postInfo>
          <p>My dataaaaaaa</p>
          <ul>
          <li for:each=postInfo for:item="post" key=post.id>post.name</li>
          </ul>
          </template>
          <template if:true=postInfo.error>
          <p>Dang</p>
          <p>postInfo.error</p>
          </template>
          </div>
          </lightning-card>
          </template>





          share|improve this answer




















          • 1





            Please update your question with latest code in your org

            – Mohith Shrivastava
            7 hours ago






          • 1





            Also note I changed variable names as well in my answer .You had same variables for your wire and track properties which could also be tht cause of the issue

            – Mohith Shrivastava
            7 hours ago






          • 1





            Check my front end code .I have changed that as well .You should use right properties

            – Mohith Shrivastava
            6 hours ago






          • 1





            I was able to get it working in my org fine

            – Mohith Shrivastava
            6 hours ago






          • 1





            On the front end you have postInfo.data , it should be postInfo.

            – Mohith Shrivastava
            6 hours ago















          2














          There are some fundamental issues with the code.



          The return type is a string as per your backend apex class and hence first thing is to parse the response into Javascript object .In your case the API is returning an Array and hence you will need an Array variable .



          Here is how the correct JS code looks like



          import LightningElement, track, wire from 'lwc';
          import getPosts from '@salesforce/apex/postController.getPosts';


          export default class JsonTest extends LightningElement

          @track postInfo = [];
          @track postId = 1;
          @track error;

          @wire(getPosts, postId: '$postId')
          getJSON(error, data)
          if (data)
          this.postInfo = JSON.parse(data);
          else if (error)
          this.error = error;





          The HTML template file is as below



          <template>
          <lightning-card title="Posts" icon-name="custom:custom67">
          <div class="slds-m-horizontal-medium">
          <template if:true=postInfo>
          <p>My dataaaaaaa</p>
          <ul>
          <li for:each=postInfo for:item="post" key=post.id>post.name</li>
          </ul>
          </template>
          <template if:true=postInfo.error>
          <p>Dang</p>
          <p>postInfo.error</p>
          </template>
          </div>
          </lightning-card>
          </template>





          share|improve this answer




















          • 1





            Please update your question with latest code in your org

            – Mohith Shrivastava
            7 hours ago






          • 1





            Also note I changed variable names as well in my answer .You had same variables for your wire and track properties which could also be tht cause of the issue

            – Mohith Shrivastava
            7 hours ago






          • 1





            Check my front end code .I have changed that as well .You should use right properties

            – Mohith Shrivastava
            6 hours ago






          • 1





            I was able to get it working in my org fine

            – Mohith Shrivastava
            6 hours ago






          • 1





            On the front end you have postInfo.data , it should be postInfo.

            – Mohith Shrivastava
            6 hours ago













          2












          2








          2







          There are some fundamental issues with the code.



          The return type is a string as per your backend apex class and hence first thing is to parse the response into Javascript object .In your case the API is returning an Array and hence you will need an Array variable .



          Here is how the correct JS code looks like



          import LightningElement, track, wire from 'lwc';
          import getPosts from '@salesforce/apex/postController.getPosts';


          export default class JsonTest extends LightningElement

          @track postInfo = [];
          @track postId = 1;
          @track error;

          @wire(getPosts, postId: '$postId')
          getJSON(error, data)
          if (data)
          this.postInfo = JSON.parse(data);
          else if (error)
          this.error = error;





          The HTML template file is as below



          <template>
          <lightning-card title="Posts" icon-name="custom:custom67">
          <div class="slds-m-horizontal-medium">
          <template if:true=postInfo>
          <p>My dataaaaaaa</p>
          <ul>
          <li for:each=postInfo for:item="post" key=post.id>post.name</li>
          </ul>
          </template>
          <template if:true=postInfo.error>
          <p>Dang</p>
          <p>postInfo.error</p>
          </template>
          </div>
          </lightning-card>
          </template>





          share|improve this answer













          There are some fundamental issues with the code.



          The return type is a string as per your backend apex class and hence first thing is to parse the response into Javascript object .In your case the API is returning an Array and hence you will need an Array variable .



          Here is how the correct JS code looks like



          import LightningElement, track, wire from 'lwc';
          import getPosts from '@salesforce/apex/postController.getPosts';


          export default class JsonTest extends LightningElement

          @track postInfo = [];
          @track postId = 1;
          @track error;

          @wire(getPosts, postId: '$postId')
          getJSON(error, data)
          if (data)
          this.postInfo = JSON.parse(data);
          else if (error)
          this.error = error;





          The HTML template file is as below



          <template>
          <lightning-card title="Posts" icon-name="custom:custom67">
          <div class="slds-m-horizontal-medium">
          <template if:true=postInfo>
          <p>My dataaaaaaa</p>
          <ul>
          <li for:each=postInfo for:item="post" key=post.id>post.name</li>
          </ul>
          </template>
          <template if:true=postInfo.error>
          <p>Dang</p>
          <p>postInfo.error</p>
          </template>
          </div>
          </lightning-card>
          </template>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 7 hours ago









          Mohith ShrivastavaMohith Shrivastava

          63.5k7 gold badges109 silver badges155 bronze badges




          63.5k7 gold badges109 silver badges155 bronze badges










          • 1





            Please update your question with latest code in your org

            – Mohith Shrivastava
            7 hours ago






          • 1





            Also note I changed variable names as well in my answer .You had same variables for your wire and track properties which could also be tht cause of the issue

            – Mohith Shrivastava
            7 hours ago






          • 1





            Check my front end code .I have changed that as well .You should use right properties

            – Mohith Shrivastava
            6 hours ago






          • 1





            I was able to get it working in my org fine

            – Mohith Shrivastava
            6 hours ago






          • 1





            On the front end you have postInfo.data , it should be postInfo.

            – Mohith Shrivastava
            6 hours ago












          • 1





            Please update your question with latest code in your org

            – Mohith Shrivastava
            7 hours ago






          • 1





            Also note I changed variable names as well in my answer .You had same variables for your wire and track properties which could also be tht cause of the issue

            – Mohith Shrivastava
            7 hours ago






          • 1





            Check my front end code .I have changed that as well .You should use right properties

            – Mohith Shrivastava
            6 hours ago






          • 1





            I was able to get it working in my org fine

            – Mohith Shrivastava
            6 hours ago






          • 1





            On the front end you have postInfo.data , it should be postInfo.

            – Mohith Shrivastava
            6 hours ago







          1




          1





          Please update your question with latest code in your org

          – Mohith Shrivastava
          7 hours ago





          Please update your question with latest code in your org

          – Mohith Shrivastava
          7 hours ago




          1




          1





          Also note I changed variable names as well in my answer .You had same variables for your wire and track properties which could also be tht cause of the issue

          – Mohith Shrivastava
          7 hours ago





          Also note I changed variable names as well in my answer .You had same variables for your wire and track properties which could also be tht cause of the issue

          – Mohith Shrivastava
          7 hours ago




          1




          1





          Check my front end code .I have changed that as well .You should use right properties

          – Mohith Shrivastava
          6 hours ago





          Check my front end code .I have changed that as well .You should use right properties

          – Mohith Shrivastava
          6 hours ago




          1




          1





          I was able to get it working in my org fine

          – Mohith Shrivastava
          6 hours ago





          I was able to get it working in my org fine

          – Mohith Shrivastava
          6 hours ago




          1




          1





          On the front end you have postInfo.data , it should be postInfo.

          – Mohith Shrivastava
          6 hours ago





          On the front end you have postInfo.data , it should be postInfo.

          – Mohith Shrivastava
          6 hours ago

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Salesforce Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f272242%2flwc-component-not-rendering%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

          Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

          Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її