• Akinci
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hello, I have this lightning data table and I want to display my respond from an API but I can't figure out how to match values to the right columns.  I tried fetching from lwc that did not work. Appreciate any help. 
 
JAVa Script

const columns = [
    { label: 'ID', fieldName: 'id' },
    { label: 'image', fieldName: 'imageType' },
    { label: 'title', fieldName: 'title', type: 'name' },
    { label: 'ready', fieldName: 'readyInMinutes', type: 'number' },
    { label: 'Serving', fieldName: 'servings' },
    { label: 'sourceURL', fieldName: 'sourceUrl' },

];

export default class bitsin extends LightningElement {
columns = columns;
data;
  
connectedCallback(){
    CallOut().then(
        result => {
            this.data = result;
                console.log('THIS THE SUCCESS MES ' + result);
        }
   ).catch( error => {
        console.error('this is the error ' + error);
   })
}

}
 
HTML 

<template>
    <div class="slds-var-m-around_small">
        <div style="height: 300px;">
            <lightning-datatable
                    key-field="id"
                    data={data}
                    hide-checkbox-column
                    columns={columns}>
            </lightning-datatable>
        </div>
                    </div>
</template>
 
Apex class

public with sharing class CallOut {
    
    @AuraEnabled(cacheable=true)
    public static string spoonacular(){
        
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        string endpoint =  ''URLSAMPLE;
        request.setEndpoint(endpoint);
        request.setMethod('GET');
        httpResponse response = http.send(request);
        string donus;
        Integer statusCode = response.getStatusCode();
        if( statusCode == 200) {
           donus = response.getBody();
           system.debug('responsee ' + response.getBody());
        } else {
            system.debug('RESPOnse: ' + response.getBody());
        }

        return donus;
        

    }

       
}
 
JSON return

[
    {
        "id": 209128,
        "imageType": "jpg",
        "title": "Dinner Tonight: Grilled Romesco-Style Pork",
        "readyInMinutes": 45,
        "servings": 4,
        "sourceUrl": "http://www.seriouseats.com/recipes/2008/07/grilled-romesco-style-pork-salad-recipe.html"
    },
    {
        "id": 31868,
        "imageType": "jpg",
        "title": "Dinner Tonight: Chickpea Bruschetta",
        "readyInMinutes": 45,
        "servings": 2,
        "sourceUrl": "http://www.seriouseats.com/recipes/2009/06/dinner-tonight-chickpea-bruschetta-babbo-nyc-recipe.html"
    },
..... and so on

 
  • February 09, 2022
  • Like
  • 2
Hello, I have this lightning data table and I want to display my respond from an API but I can't figure out how to match values to the right columns.  I tried fetching from lwc that did not work. Appreciate any help. 
 
JAVa Script

const columns = [
    { label: 'ID', fieldName: 'id' },
    { label: 'image', fieldName: 'imageType' },
    { label: 'title', fieldName: 'title', type: 'name' },
    { label: 'ready', fieldName: 'readyInMinutes', type: 'number' },
    { label: 'Serving', fieldName: 'servings' },
    { label: 'sourceURL', fieldName: 'sourceUrl' },

];

export default class bitsin extends LightningElement {
columns = columns;
data;
  
connectedCallback(){
    CallOut().then(
        result => {
            this.data = result;
                console.log('THIS THE SUCCESS MES ' + result);
        }
   ).catch( error => {
        console.error('this is the error ' + error);
   })
}

}
 
HTML 

<template>
    <div class="slds-var-m-around_small">
        <div style="height: 300px;">
            <lightning-datatable
                    key-field="id"
                    data={data}
                    hide-checkbox-column
                    columns={columns}>
            </lightning-datatable>
        </div>
                    </div>
</template>
 
Apex class

public with sharing class CallOut {
    
    @AuraEnabled(cacheable=true)
    public static string spoonacular(){
        
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        string endpoint =  ''URLSAMPLE;
        request.setEndpoint(endpoint);
        request.setMethod('GET');
        httpResponse response = http.send(request);
        string donus;
        Integer statusCode = response.getStatusCode();
        if( statusCode == 200) {
           donus = response.getBody();
           system.debug('responsee ' + response.getBody());
        } else {
            system.debug('RESPOnse: ' + response.getBody());
        }

        return donus;
        

    }

       
}
 
JSON return

[
    {
        "id": 209128,
        "imageType": "jpg",
        "title": "Dinner Tonight: Grilled Romesco-Style Pork",
        "readyInMinutes": 45,
        "servings": 4,
        "sourceUrl": "http://www.seriouseats.com/recipes/2008/07/grilled-romesco-style-pork-salad-recipe.html"
    },
    {
        "id": 31868,
        "imageType": "jpg",
        "title": "Dinner Tonight: Chickpea Bruschetta",
        "readyInMinutes": 45,
        "servings": 2,
        "sourceUrl": "http://www.seriouseats.com/recipes/2009/06/dinner-tonight-chickpea-bruschetta-babbo-nyc-recipe.html"
    },
..... and so on

 
  • February 09, 2022
  • Like
  • 2
We use forms that we send to our accounts to collect information over time. The fields are all in Accounts object. I would like to have different Record pages that match up the fields to each form. For example I have App "Forms Data" and with in it I have a "Sign Up" page displaying the Account object and Record Details Component showing fields that match the fields on the Sign Up form. Then I have a Records page "Additional Interests" and that is on Accounts object too but it has a Record Details Component showing only the fields matching to the "Additional Interest" form. So I want different views of the Account object within the same App, for same record type, for same user. Can I do this within same App? So far I think I have to use multiple Apps.