Hi Brewmaster (love the name
)
The dataset is Blog/Posts, the #post1 is the post viewer object on the post page of the blog
The following code works published, but I get a TypeDef error in preview mode.
import wixData from 'wix-data';
import wixLocation from 'wix-location';
$w.onReady(function () {
wixLocation.onChange((location) => {
initPage()
});
initPage()
})
async function initPage() {
$w('#post1').getPost().then(async (res) => {
console.log("We have the post")
assignPostDataToUIElements(res)
})
.catch((error) => {
console.log('We have an error')
console.log(error);
})
}
async function assignPostDataToUIElements(postRes) {
let info = await postRes
console.log(info)
$w("#postTitle").text = await info.title
$w("#postHeaderStrip").background.src = await info.coverImage
}