Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does anyone else have a problem with deleting/updating an annotation? #703

Open
ECannon opened this issue Jun 19, 2019 · 4 comments
Open

Comments

@ECannon
Copy link

ECannon commented Jun 19, 2019

Hi, I am using annotator v 2., I have annotator saving annotations and loading them again on page load, however when I try to delete or update the annotation I get an error 'annotation must have an id for delete()' and similar for update.

Has anyone had any problems with this before?

P.S my backend is fine and set up as per the documentation (works with postman) but I must be missing something on the front end, any help is appreciated.

Thanks.

@tilgovi
Copy link
Member

tilgovi commented Jun 19, 2019

The annotations must have an id property to delete them, according to the way the storage system is written. If you are returning annotations from your server on page load, make sure you assign each of them an id property.

https://github.com/openannotation/annotator/blob/master/src/storage.js#L599

@ECannon
Copy link
Author

ECannon commented Jun 19, 2019

Thanks for your timely reply. When I create an annotation I am storing them in mongoDB which will automatically create an id, however this id is not being sent in the url when I click the delete (x) on the annotation. When I am creating an annotation and then storing the annotation there is also no id being sent in the request body, only quote, ranges, text and uri. I would not have the uri in the body only that I included it on the client side. Do i have to do the same with the id?

@tilgovi
Copy link
Member

tilgovi commented Jun 19, 2019

You need to include the id in the body. If I remember correctly, MongoDB might add an _id field, but you will have to format this as id or change the storage adapter to suit your needs.

After you save an annotation, you will want to also update the new annotation by returning the annotation, with its new id.

@ECannon
Copy link
Author

ECannon commented Jun 20, 2019

That's exactly it, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants