Published
Edited
Mar 30, 2022
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
async function query(sql, params) {
const res = await fetch('https://bq-cors.vercel.app/api/', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query: sql, params })
})

if (res.ok) {
let queryResult = await res.json()
return queryResult
} else {
const contentType = res.headers.get('content-type')
if (contentType && contentType.indexOf('application/json') !== -1) {
const error = await res.json()
throw Error(error.message)
} else {
throw Error(await res.text())
}
}
}
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more