Parse API connection error

that is not latest version, but it should still work
same code works somewhere else, for that initMoralis function?

Well the code works on my PC, but just not on the server

what could be the difference?

Could it be something like that itā€™s a testnet server or something in the settings in the dashboard else I donā€™t have an idea, it has been really frustrating that it doesnā€™t work haha.

exactly same code works on your PC and not on another one?

I havenā€™t tested it on an other pc, do you want me to try that?

with exact server url and app id works on your PC?

how do you send the code on the server, is the code identical?

With the exact server url and app id yes, Iā€™ve zipped the code -> uploaded to the server -> unzipped the code

maybe you can try to run a simple js script on the server manually to see how it works, it looks like there is some kind of server running there in js when it doesnā€™t work

Sorry what do you exactly mean with this?

from the initial image, it looks like something more complex than a script with 10 lines of code that runs

So Iā€™ve made like a simple 1 function test code and it returned to owner of the nft inserted (this is the right id) but a bit later it gave the error again, so is it maybe like an error that itā€™s trying to connect a lot which causes it to error?

it looks like a different type of issue now, maybe you can add more debugging with console.log to see how many times it is called

Well itā€™s weird because itā€™s only fired once atm and it prints like something infront of the ā€œMoralis.startā€ and it takes like 5-10 seconds but in the mean time it can do the functions.

So what do you think that the problem could be @cryptokid?

I donā€™t know exactly, I donā€™t have enough information

try to add some debugging, run a simpler script

I mean itā€™s just 1 function and itā€™s still getting the error

const express = require("express");
const Moralis = require('moralis/node');
var Web3 = require('web3');


const app = express();

const { MANAGER } = require("./config/smartcontracts.config");
const { managerABI } = require("./abis/manager");
// Initizalise
async function initMoralis(){
    const start = await Moralis.start({ serverUrl: "", appId: "" }).catch((err) => { console.log(err) });
    console.log(Moralis.CoreManager.get("VERSION"))
}

initMoralis();

async function getNFTOwner(){
    const address = '0x8bac6324c21b3db9d385a9172cea41ff36669f41'
    const tokenId = 1
	const endPoint = '';
	const provider = new Web3.providers.HttpProvider(endPoint);
	web3 = new Web3(provider);

	contract = new web3.eth.Contract(managerABI, MANAGER)
	const owner = await contract.methods.getTokenOwner(address, tokenId).call().catch((err) => { console.log(err) });
	
	console.log(owner)
}

// Repeat get all items every x minutes
setInterval(getNFTOwner, 1000); // 60.000 is 1 minute.

  

// Start server
app.listen(4000, () => {
 	console.log("API has been started on port 4000!");
})

try to use await here maybe

where was the endpoint initialized?

in particular this code doesnā€™t need moralis, as it doesnā€™t use any feature from it like web3api

If you would want to do that it should be done in the listen I think
like this:


// Start server
app.listen(4000, async() => {
    await initMoralis()
 	console.log("API has been started on port 4000!");
})

But that still gives the same error