dajk / hltv-api

DEPRECATED: An unofficial JSON api for popular CS:GO website hltv.org. Check available methods on https://hltv-api.vercel.app/
http://npm.im/hltv-api
MIT License
277 stars 59 forks source link

Getting Error on NodeJs #78

Closed yashkathe closed 2 years ago

yashkathe commented 2 years ago

/home/yashkathe/NODEJS-projects/CLONES/csgo-news/node_modules/hltv-api/dist/teams.js:72 throw new Error(error); ^

Error: Error: There are no teams available, something went wrong. Please contact the library maintainer on https://github.com/dajk/hltv-api at Object. (/home/yashkathe/NODEJS-projects/CLONES/csgo-news/node_modules/hltv-api/dist/teams.js:72:19) at Generator.next () at fulfilled (/home/yashkathe/NODEJS-projects/CLONES/csgo-news/node_modules/hltv-api/dist/teams.js:5:58) at processTicksAndRejections (node:internal/process/task_queues:96:5)

Ta1al commented 2 years ago

I think it has been 2 weeks since the API stopped working

yashkathe commented 2 years ago

And here I was, trying to refactor my code thinking I was doing something wrong. Well thanks for informing and do update this thread if the api is back up again. Thank you

tavindev commented 2 years ago

I did some testing and concluded the problem is that HLTV is blocking all requests because of bot protection. Changing the User-Agent in the source code from node-fetch to a real User-Agent solved the issue.

Using the user-agents library to generate a User-Agent, instead of using node-fetch, might be a good solution to this.

dajk commented 2 years ago

Thanks for pointing this out, the fix has been released...closing..