Skip to content

Instantly share code, notes, and snippets.

@zahqresh
Created July 19, 2021 04:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zahqresh/224cc35c154c1ae0c403da71c75d9e9b to your computer and use it in GitHub Desktop.
Save zahqresh/224cc35c154c1ae0c403da71c75d9e9b to your computer and use it in GitHub Desktop.
//Create annotations
app.post('/api/annotations/:name', (req, res) => {
//create a random id object for annotations
let id = uuidv4();
const {
qoute,
ranges,
text
} = req.body;
const {
name
} = req.params;
//create object
let annotObj = {
"id": id,
"quote": qoute,
ranges: ranges,
text: text
};
//save annotation object and send the response to create annotation
db({
file_name: name,
rows: annotObj,
id: id
}).save().then(doc => {
res.json(doc.rows);
})
console.log(req.body);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment