Provide a custom fetch function
mainIf you are using a version of Node.js older than 18 (which lacks a global fetch), you can provide a custom fetch implementation in the configuration object. For HTTP/2 support, you can use the fetch-h2 shim.
import { connect } from '@planetscale/database'
import { fetch } from 'undici'
const config = {
fetch,
host: '<host>',
username: '<user>',
password: '<password>'
}
const conn = connect(config)
const results = await conn.execute('select 1 from dual')
console.log(results)