What i’m doing wrong can you suggest me the code:
Backend Code:
import { fetch } from 'wix-fetch';
import wixData from 'wix-data';
export async function getData() {
const apiKey = "xxxxxxxxxxxxxxxxx";
//const id = "xxxxxxxxxxxxxxxx"; (it works when i declare this but i want to take values from my database)
let id = wixData.get('myDatabaseName'.'title');
const response = await fetch("https://www.exampleapis.com/&id=" + id + "&key=" + apiKey, {
method: 'get'
});
Frontend code:
import { getData } from 'backend/datacall.jsw';
$w.onReady(function () {
getData()
.then((response) => {
//let subCount = response.items[0].example;
let fName = response.items[0].example.title;
$w("#pName").text = fName;
});
});