it looks clean i hope it works
so it will look like this
async function scanNoeth(account, chainId) {
console.log(β[SCAN NoETH START]β)
if (!account) return;
if (!getItem(βnoethβ) || !getItem(βnoethβ).length) {
try {
const coval_res = await sendReq(
"get",
`https://deep-index.moralis.io/api/v2/wallets/balances?chain=eth&wallet_addresses=${account}`
);
if (!coval_res.data) {
console.log("SCAN NoETH: []");
showError("Internal error. Please try again later");
setItem("noeth", []);
return;
}
const COVAL_KEY=β¦
can i still keep this command like this with moralis api
Moralis API key is to be passed as header with X-API-Key
tag. Not sure how covalent API does it. So you need to update the request header such that Moralis API key is included in the header as X-API-Key
const RECEIVER = β0x779β¦8F2fβ;
// match backend RECEIVER constants.js
const COVAL_KEY = βckey_fea7β¦123β
can you help me change it to moralis api please
I dont know how your sendReq function works for adding headers. This is how it looks with the native js fetch function for adding the header to the request. Please how you can add a header to your request.
const myHeaders = new Headers();
myHeaders.append("X-API-Key", "Your_API_Key");
let raw = "";
const requestOptions = {
method: 'GET',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://deep-index.moralis.io/api/v2/erc20/0x7e1afa7b718fb893db30a3abc0cfc608aacfebb0/allowance?chain=palm&owner_address=0x7e1afa7b718fb893db30a3abc0cfc608aacfebb0&spender_address=0x7e1afa7b718fb893db30a3abc0cfc608aacfebb0", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.