Moralis Cli error

Trying to config auto sync cloud functions code from IDE using

moralis-admin-cli watch-cloud-folder 

and getting the following error:

This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: read ECONNRESET
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)

I can confirm moralis-admin-cli is installed globally, AKI keys and secrets correct as the command is directly copied from the config instruction

Can you share more details on how to recreate the same error.

I looks like it can not connect somewhere from that error

Thanks guys. The issue was due to the network connectivity.

1 Like

I’m getting a similar error, following the command to setup cloud watch. For my path I did the full path like below, and also tried simply \cloud and get the same error.

C:\Users\brett\Documents\dashboard>moralis-admin-cli watch-cloud-folder --moralisApiKey xxx --moralisApiSecret xxx --moralisSubdomain xxx.usemoralis.com --autoSave 1 --moralisCloudfolder c:\users\brett\documents\dashboard\cloud
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: Request failed with status code 403
at createError (C:\Users\brett\AppData\Roaming\npm\node_modules\moralis-admin-cli\node_modules\axios\lib\core\createError.js:16:15)
at settle (C:\Users\brett\AppData\Roaming\npm\node_modules\moralis-admin-cli\node_modules\axios\lib\core\settle.js:17:12)
at IncomingMessage.handleStreamEnd (C:\Users\brett\AppData\Roaming\npm\node_modules\moralis-admin-cli\node_modules\axios\lib\adapters\http.js:269:11)
at IncomingMessage.emit (node:events:539:35)
at IncomingMessage.emit (node:domain:475:12)
at endReadableNT (node:internal/streams/readable:1345:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)

try to copy the credentials from the legacy interface: legacy.moralis.io

that error looks like the used credentials were not the right ones

same error, they seem to be identical credentials, however I see I can actually code in this version of the website. So maybe I just do that? Is this the only way to call APIs outside of the built in wrappers? Put the calls in cloud files?

I don’t know the exact context for what you want to do. You can call web3api functions directly in front end or in the backend too

I’m trying to learn moralis and these api calls step by step. I was able to take the ethereum-boilerplate and get that working to only show my NFTs. Now I want to customize the boilerplate and simply add a token price via api. Any token price, eth, avax, bsc, just to understand how an api call works. This post ’ [SOLVED] Problem to get the price of a token on my site’ Is exactly what I am trying to accomplish next. I even created an index page, main js, and I have a cloud function to get the price (not sure if that is necessary) and nothing happens for me when I navigate to the index page.

Do you know how I could call main.js just like in that post, but from the app.jsx file in the ethereum-boilerplate? I just want to figure out how to call an API and put a price up on the header next to the chain and connected wallet address. Then maybe I can slowly learn more things to use APIs for. Just want 1 api call to work for me haha.

you can check the documentation for how to make that call in react:
https://docs.moralis.io/moralis-dapp/web3-api/token#gettokenprice

Do I put this right in app.jsx, or does it need to be in a separate file?

import React from “react”;
import { useMoralisWeb3Api } from “react-moralis”;

const Web3Api = useMoralisWeb3Api();

const fetchTokenPrice = async () => {
//Get token price on PancakeSwap v2 BSC
const options = {
address: “0x42F6f551ae042cBe50C739158b4f0CAC0Edb9096”,
chain: “bsc”,
exchange: “PancakeSwapv2”,
};
const price = await Web3Api.token.getTokenPrice(options);
console.log(price);
};

oh maybe I sort of copy chains.jsx, make a price.jsx, and then call that in app.jsx? I tried this and received this. I feel like I’m running in circles.

src\components\Price\Price.jsx
Line 1:8: ‘React’ is defined but never used no-unused-vars
Line 4:17: React Hook “useMoralisWeb3Api” cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function react-hooks/rules-of-hooks

I don’t know exactly, you can call the vanilla js version too if it is easier for you

Line 1:8: ‘React’ is defined but never used no-unused-vars

You can ignore this.

Line 4:17: React Hook “useMoralisWeb3Api” cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function react-hooks/rules-of-hooks

Hooks (functions that start with use) can only be used in function components (components starting with a capital letter e.g. App) or in other hooks. You can read the Rules of Hooks

So put all your code (except for import React from "react" which stays at the top of the file) inside the App component.

I’m going to take a few days away from this stuff, definitely not connecting a wallet.