0

I am fetching a simple API, and everything works fine when displaying in the console, but then I catch a very weird error in the Brave Browser console, and that's why I cannot display anything in html. I have one API that works just fine and another similar API that throws this error :

GET https‍://api.bscscan.com/api?module=stats&action=tokenCsupply&contractaddress=0xde301D6a2569aEfcFe271B9d98f318BAee1D30a4&apikey=E2JAJX6MAGAZUHSYIBZIEMKMNW9NZKPR7I
net::ERR_BLOCKED_BY_CLIENT

My code :

import Head from 'next/head'
import styles from '../styles/Home.module.css'
import {
  bsctokendata
} from "../pages/bscdatanew/data";
import React, {
  useEffect,
  useState
} from "react";
import {
  useRouter
} from "next/router";


export default function Test() {

  let loco = async() => {

    function apitest() {
      //below is displaying weird error but in console all good
      let bscbalance = 'https://api.bscscan.com/api?module=stats&action=tokenCsupply&contractaddress=0xde301D6a2569aEfcFe271B9d98f318BAee1D30a4&apikey=E2JAJX6MAGAZUHSYIBZIEMKMNW9NZKPR7I'
      //below is working fine
      // let bscbalance = 'https://api.bscscan.com/api?module=account&action=tokenbalance&contractaddress=0xde301D6a2569aEfcFe271B9d98f318BAee1D30a4&address=0x65d9cb422517127f1dd997a05274ab16264330b6&tag=latest&apikey=E2JAJX6MAGAZUHSYIBZIEMKMNW9NZKPR7I'


      return bscbalance;
    }

    let url = await apitest();

    const addressbalance = await fetch(url)

    console.log(addressbalance)

    const databal = await addressbalance.json();

    console.log(databal)
  }

  loco()
  
    return (
    <div style={{ padding: 40 }}>
    </div>
  );
}

Here are 2 pictures of the console to show that the working api and the not working api have the same results in the console:

Working API

Not working API

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Loco2343
  • 25
  • 1
  • 1
  • 5
  • Both the pics show response status 200. What is the log of `databal` for the *non working* fetch ? – Cesare Polonara May 01 '22 at 10:43
  • If there are any ad blockers turn it off. Read more in [Ad Block](https://stackoverflow.com/questions/23341765/getting-neterr-blocked-by-client-error-on-some-ajax-calls) – Hakob Sargsyan May 01 '22 at 10:45
  • nextjs Client-side data fetching with useEffectL https://nextjs.org/docs/basic-features/data-fetching/client-side – Oleg May 01 '22 at 10:47
  • @CesarePolonara that's the console.log : 'GET https://api.bscscan.com/api?module=stats&action=tokenCsupply&contractaddress=0xde301D6a2569aEfcFe271B9d98f318BAee1D30a4&apikey=E2JAJX6MAGAZUHSYIBZIEMKMNW9NZKPR7I net::ERR_BLOCKED_BY_CLIENT' – Loco2343 May 01 '22 at 12:09

0 Answers0