node-ytdl-core icon indicating copy to clipboard operation
node-ytdl-core copied to clipboard

Need help with importing util

Open JamesTiberiusKirk opened this issue 9 years ago • 3 comments

Hi, noob here.

I need to import util so I can use the validateLink function. The documentation is a bit unclear for me. In the beginning I tried to simply do const ytdl = require('ytdl-core') with ytdl.validateLink(url), that didn't work. Then, I tried to const {util} = require('ytdl-core') and util.validateLink(url), which didn't work either.

What is the proper way to import util? Thanks in advance!

JamesTiberiusKirk avatar Aug 29 '17 17:08 JamesTiberiusKirk

Not your mistake, the readme clearly says validateLink() but apparently it's validateId() according to this line.

const ytdl = require('ytdl-core')
ytdl.validateId(url);

@fent Either the readme or index.js should be updated accordingly.

BrunoMoreira99 avatar Aug 30 '17 04:08 BrunoMoreira99

This still doesn't seem to work for some reason. Keep getting the same error. Uncaught TypeError: ytdl.validateId is not a function And I am using it in the exact same way that you are.

JamesTiberiusKirk avatar Aug 30 '17 08:08 JamesTiberiusKirk

guess that one is on me... gonna make a pr real quick try updating ytdl-core @JamesTiberiusKirk , u may still be on an older version

TimeForANinja avatar Aug 30 '17 09:08 TimeForANinja