I have created a custom element using corvid (now vello) now I want to show data from the collection. But whenever I add import wixData **from** 'wix-data' ;
in my corvid file my element disappears from the page. So I am entirely not sure how to proceed with this.
Get the data on the page code, convert it into a string (for example, using JSON.stringify() ) then set the data as a custom element attribute value using .setAttribute()
On the custom element class, observe attribute change and handle the change as you wish.
See:
https://www.wix.com/velo/reference/$w/customelement/setattribute
https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements
You can create a REST api for collects/prepares data and sends to custom on a fetch “get”. Using custom attribute is more easy but all attributes go through DOM.