Created
July 19, 2021 04:23
-
-
Save zahqresh/224cc35c154c1ae0c403da71c75d9e9b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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