the-forest/server/dbHelper.js

19 lines
407 B
JavaScript

// helper function(s?) to make a query to the database
const db_url = 'http://localhost:8000'
async function query(q, params) {
return fetch(db_url, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
statements: [{
q: q,
params: params
}]
})
}).then((res) => res.json())
.then((data) => data[0].results);
}
module.exports = { query: query };