Hello! I am having a pretty hard time getting the Dex swap box options to show a list of available tokens. At first my server was stuck at 100% CPU, then it couldnt recognize the 1inch plugin, and now I am getting these errors when I inspect element on Live Server:
index.html:117 Live reload enabled.
iqvaw6azff7h.usemora…ns/getPluginSpecs:1 Failed to load resource: the server responded with a status of 400 ()
moralis.js:25632 Uncaught (in promise) Error: Invalid function: "getPluginSpecs" at handleError (moralis.js:25632)
iqvaw6azff7h.usemora…ns/getPluginSpecs:1 Failed to load resource: the server responded with a status of 400 ()
moralis.js:25632 Uncaught (in promise) Error: Invalid function: "getPluginSpecs" at handleError (moralis.js:25632)
I am not sure what this means I need to look at in my code. Here is my JS file:
/** Connect to Moralis server */
const serverUrl = "https://XYZ";
const appId = "ABC";
Moralis.start({ serverUrl, appId });
async function init(){
await Moralis.initPlugins();
await Moralis.enable();
await listAvailableTokens();
}
async function listAvailableTokens(){
const result = await Moralis.Plugins.oneInch.getSupportedTokens({
chain: 'polygon',
});
const tokens = result.tokens;
let parent = document.getElementById("token_list");
for( const address in tokens){
let token = tokens[address];
let div = document.createElement("div");
div.className = "token_row";
let html = `
<img class="token_list_img" src="${token.logoURI}">
<span class="token_list_text">${token.symbol}</span>
`
div.innerHTML = html;
parent.appendChild(div);
}
}
async function login() {
let user = Moralis.User.current();
if (!user) {
try {
user = await Moralis.authenticate({ signingMessage: "Hello World!" })
console.log(user)
console.log(user.get('ethAddress'))
} catch(error) {
console.log(error)
}
}
}
function openModal(){
document.getElementById("token_modal").style.display = "block";
}
function closeModal(){
document.getElementById("token_modal").style.display = "none";
}
document.getElementById("modal_close").onclick = closeModal;
document.getElementById("from_token_select").onclick = openModal;
document.getElementById("login_button").onclick = login;
/*async function logOut() {
await Moralis.User.logOut();
console.log("logged out");
}*/
init();
Thank you so much!