The signature of 'parse' is deprecated

Viewed 259

I am creating a node server, but there is an obsolete function. I have the following error in my code:

The signature '(urlString: string): UrlWithStringQuery' of 'parse' is deprecated.ts(6387)
url.d.ts(63, 8): The declaration was marked as deprecated here.
(alias) parse(urlString: string): UrlWithStringQuery (+3 overloads)
import parse
The url.parse() method takes a URL string, parses it, and returns a URL object.

A TypeError is thrown if urlString is not a string.

My code is:

    server.on('request', function (req, res) {
 var filename = parse(req.url).pathname,
     fullPath,
     extension;

 ...

What can I use instead of parse(req.url).pathname?

0 Answers
Related