Please i need help on how to convert an api of another source to moralis API

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.