jJ
07/24/2022, 3:22 PMjavascript
// index.ts
import { serve } from "https://deno.land/std@0.131.0/http/server.ts"
import puppeteer from "https://deno.land/x/puppeteer@9.0.0/mod.ts";
import { cheerio } from "https://deno.land/x/cheerio@1.0.6/mod.ts";
serve(async (req) => {
const { url } = await req.json()
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(url);
const html = await page.content();
const $ = cheerio.load(html);
const title = $('title');
const data = {
title: title,
}
return new Response(
JSON.stringify(data),
{ headers: { "Content-Type": "application/json" } },
)
})
on
supabase functions deploy myfunc
returns:
bash
Error: Error bundling function: exit status 1
error: TS2339 [ERROR]: Property 'load' does not exist on type '(selector: any, context: any, root: any, opts: any) => any'.
const $ = cheerio.load(html);
Many thanks in advance, Joe