Skip to content

Instantly share code, notes, and snippets.

@hand-dot
Last active June 17, 2023 05:24
Show Gist options
  • Select an option

  • Save hand-dot/43d6c60b5e704ec01764caafa364a87c to your computer and use it in GitHub Desktop.

Select an option

Save hand-dot/43d6c60b5e704ec01764caafa364a87c to your computer and use it in GitHub Desktop.
import { ok, serverError } from 'wix-http-functions';
import { sql } from '@velo/wix-data-sql-backend';
/**
* @param {import("wix-http-functions").WixHttpFunctionRequest} request
*/
export async function post_sql(request) {
try {
const reqBody = await request.body.json()
const result = await sql(reqBody.sqlStr);
return ok({
body: { result },
headers: { 'Content-Type': 'application/json' },
})
} catch (error) {
console.error('error: ', error)
return serverError({
body: error,
headers: { "Content-Type": "application/json" }
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment