Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript How to get database field value in backend?

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #297487
    Shantanu
    Participant

    Hi,

    I learned the javascript recently & on Wix, I’m using the javascript to develop a website for practice using Wix corvid (Hope you guys familiar). My code is up & running but in one place I’m not able to understand how can I do it that’s why I’m looking for the answer.

    The project is to fetch the details via API & show on page repeater via backend code.
    Below code is on backend here I want to call database item value in “id” but the problem is when I write -> const id = “xxxxx” it will run the code successfully on the front end in repeater but when I’m using “let” it’s not taking any value from the database to show on the repeater.

    Remember every database item has different values & I want to show the data on the repeater for every item.

    import { fetch } from ‘wix-fetch’;
    import wixData from ‘wix-data’;

    export async function getData() {

    const apiKey = "xxxxxxxxxxxxxxx";
    const id = "xxxxxxxxxxxxx" ; // static value 
    
    let id = $w("#myDatabaseName").getCurrentItem().title; // here i want to take database item value to show the data on repeater
    
    const response = await fetch("https://www.exampleapis.com/ample?id=" + id + "&key=" + apiKey, {
        method: 'get'
    });
    

    Looking for your suggestions

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.