Iām working on getting a proof of concept going for Wix integration so I can give myself a trajectory of learning. Wix has really annoying code integration tools, but I donāt need that much extra for what Iām doing and if I can make this work, itāll save me a toooooon of time with not having to create a complex custom website. Basically trying to get their first call function to work on Wix, just to get my bearings, and I canāt figure it out.
Iāve tried making a custom element, but that only attaches to the java code and a custom HTML file wonāt associate with the java code. I donāt really know how the file structures work in Wix, but I made the test.js in root, so I figured the html calling for java.js to be in root would work, but it doesnāt. Does anyone have any advice for how to get this to work properly? Thank you in advance!
This is the code from the tutorial (obv in my code, I have my API key replacing the āyour API keyā bit):
Firstly open your index.html file and add this code, it simply calls your javascript and adds a result area to print your data.
1<h1>Moralis API Response:</h1>
2<div id="result"></div>
3<script src="./test.js"></script>
Secondly open your Javascript file and copy and paste this Javascript code there. It will make a data query to Ethereum Chain, Block number 1000.
1const options = {
2 method: 'GET',
3 headers: { 'Accept': 'application/json', 'X-API-Key': 'your API Key' },
4};
5fetch('https://deep-index.moralis.io/api/v2/block/1000?chain=eth', options)
6 .then((response) => response.json())
7 .then((response) => printResult(response))
8 .catch((err) => console.error(err))
9
10const printResult = (response) => {
11 const container = document.getElementById('result')
12 container.innerHTML = "<pre>" + JSON.stringify(response ,null, 2) + "</pre>"
13}