cheerio icon indicating copy to clipboard operation
cheerio copied to clipboard

Incorrect code example in intro documation

Open VictorPersson opened this issue 2 years ago • 0 comments

I was reading the "Basic loading" documentation and pressed the copy button in order to receive the intro code from the docs:

import * as cheerio from 'cheerio';

const $ = cheerio.load('<html><body><h1>Hello, world!</h1></body></html>');

console.log($('title').text());
// Output: Hello, world!

However, the console log turns out empty is empty. This is because it's trying to select and log "title" which does not exist in the provided code: <html><body><h1>Hello, world!</h1></body></html>

So the output "// Output: Hello, world!" is just ""

VictorPersson avatar Aug 27 '23 17:08 VictorPersson