Closed msavitskiy closed 4 years ago
code ` const { HLTV } = require("hltv"); const express = require("express"); const app = express(); const port = 3000;
app.get("/", (req, res) => { HLTV.getMatches().then((matches) => { var id = matches[0].id; console.log({ id }); HLTV.getMatch(id).then((match) => { res.send(match); }); }); });
app.listen(port, () => {
console.log(Example app listening at http://localhost:${port}
);
});
`
Example app listening at http://localhost:3000
{ id: 2343402 }
(node:1566) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'split' of undefined
at node_modules/hltv/lib/endpoints/getMatch.js:96:93
at step (node_modules/hltv/lib/endpoints/getMatch.js:33:23)
at Object.next (node_modules/hltv/lib/endpoints/getMatch.js:14:53)
at fulfilled (node_modules/hltv/lib/endpoints/getMatch.js:5:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:1566) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1566) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
package.json
{ "name": "", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "express": "^4.17.1", "hltv": "^2.20.1" } }
Look at already closed issues: https://github.com/gigobyte/HLTV/issues/320
You're probably making too many request and cloudflare blocks your access.
I tried from GCP(different ip) and have the same exception. And in browser HLTV works properly
The tests are passing on my machine.
Cannot read property 'split' of undefined hltv/lib/endpoints/getMatch.js:96:93