TypeError: $w(...).getPost is not a function

What is the solution for this? :triumph::triumph::triumph::triumph::triumph::triumph:
This is the code which given by the Corvid in the examples section and the same website itself.


https://www.wix.com/corvid/example/custom-post-page

I am not able to sort this out. Anybody out, who knows whats wrong?

import wixData from 'wix-data';
let currentPost
$w.onReady(function () {
$w("#post1").getPost().then(async post => {
currentPost = await loadExtraPostData(post)
assignPostDataToUIElements()
});
})
async function loadExtraPostData(post) {
let postDataFromCollection = await wixData.query("PostExtraData")
.eq("post", post._id)
.find()
postDataFromCollection = postDataFromCollection.items[0]
return mergePostData(post, postDataFromCollection)
}
async function mergePostData(post, extraData) {
return Object.assign({}, post, extraData)
}
function assignPostDataToUIElements() {
$w("#postTitle").text = currentPost.title
$w("#authorName").text = `Written by: ${currentPost.author}`
$w("#photographerName").text = `Images by: ${currentPost.photographer}`
$w("#postHeaderStrip").background.src = currentPost.coverImage
$w("#postHeaderStrip").show("fade")
}

1 Like

Does it only happen in the preview? Did you check the live site?
We have an ongoing issue with getPost() and this error however it only shows this error in the preview in your Editor and on the live site the functionality is working.
If your error appears only in preview - we are aware of this issue and we are already working on resolving it!

no it is not working. I am sure I checked in the live site too but not working.

@foodwhispersindia please open ticket so we can take a look at your Editor and investigate further!

https://support.wix.com/en/article/contacting-wix-support

Hey @yevheniias ,

I am also experiencing this issue and it seems to be affecting the live site too I think.

Thanks

Hey!

We are investigating this issue. Seems that it affects preview mode only. Please let me know in case it affects your live site.

I will update you when this issue will be fixed. Apologies for the inconvenience.

Hey guys, when I try to see the author on the live site for the BlogPost, it’s resolving to an empty string.

@chris-derrell Unfortunately, Author is not available in getPost() or Posts collection.

@juliuss That’s really strange to hear, because the Author column has popped up in My Database and in my console when I logged getPost().

Hey all!
Just to inform you, getPost issue in preview mode was fixed.

@chris-derrell , Author field from the Posts collection and getPost() was removed until this feature will be implemented. We apologise for the confusion.

@juliuss No problemo. Looking forward to that feature.