-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Hi, thanks for this amazing package,
when I'm playing around with user-defined function, I came across this issue.
The code snippet below only give me Promise, not the actual string.
async function fetchFromHttp() {
const db = await Database.create(":memory:");
db.register_udf('css_selector', 'string', (url) => {
console.log(`fetching from url: ${url}`);
const data = fetch(url)
.then(res => res.text())
.then(data => {
return data;
});
return data;
});
const rows = await db.all(`select css_selector('https://example.com/') as html`);
await db.wait();
console.log(rows);
}
await fetchFromHttp();
$ yarn start
yarn run v1.22.21
$ node src/index.js
fetching from url: https://example.com/
[ { html: '[object Promise]' } ]
Metadata
Metadata
Assignees
Labels
No labels