Coinpaprika.com blocked error

hello everyone

I’m receiving the following errors. im currently on the dex javascript project

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.coinpaprika.com/v1/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 404.

Uncaught (in promise) TypeError: NetworkError when attempting to fetch resource.

im able too log into metamask but im not sure why im getting this error. this is my current code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


        <!-- Moralis SDK code -->
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web3.min.js"></script>
        <script src="https://unpkg.com/[email protected]/dist/moralis.js"></script>

        <title>Moralis Dex </title>

</head>


<body>
    
    
    <button id="btn-login">Moralis Login</button>
    <button id="btn-logout">Logout</button>


    <script src="./dex.js"></script>

</body>
</html>


    // connect to Moralis server

      const serverUrl = "**************************";
      const appId = "*******************";
      Moralis.start({ serverUrl, appId });


     // add from here down
     async function login() {
      let user = Moralis.User.current();
      if (!user) {
        user = await Moralis.authenticate();
      }
      console.log("logged in user:", user);
    }

    async function getStats()
    
    {
      const balances = await Moralis.Web3API.account.getTokenBalances();
      console.log (balances);



    }



    async function logOut() {
      await Moralis.User.logOut();
      console.log("logged out");
    }

    document.getElementById("btn-login").onclick = login;
    document.getElementById("btn-logout").onclick = logOut;


async function getTop10tokens() {
    const response = await  fetch (' https://api.coinpaprika.com/v1/ ');
    const tokens  =  await response.json();

    return tokens.filter( token => token.rank <= 10).map(token => token.symbol);

}

async function gettickerdata() {
    const response  = await fetch ('https://api.1inch.exchange/v3.0/137/tokens');
    const tokens =  await response.json ();
    const tokenlist = object.values(tokens.tokens);

    return tokenlist. filter(token => tickerlist.includes(token.symbol));

}

getTop10tokens()
    .then(gettickerdata)
    .then(console.log);

does anyone know why this is happening?

It looks like https://api.coinpaprika.com/v1/ is not working.

that makes sense. should the code typically work when the api is up?

what source should i use if coin paprika is down too test my code?

Yeah if the website is working you should be able to fetch the data with your code.

I am not sure what type if data you are looking for. You can give a try with coingecko api.

That Paprika API seems fine but you haven’t passed anything into it.

E.g. if you change the fetch to https://api.coinpaprika.com/v1/coins, you get some data back from tokens.

Have a look at the docs to find out what to use for the data you want.

1 Like

thank you that made my error go away :slight_smile: