fix(hypothesis): correctly set headers when fetching from hypothesis
The issue
When we publish to hypothesis, to decide whether we need to create/update/delete a field we check if there exists hypothesis annotation ID for that: https://gitlab.coko.foundation/kotahi/kotahi/-/blob/57fb44d4b60e8cd94f1ac1af096d713d250c3832/server/publishing/hypothesis/index.js#L96-100
This works fine, but there is an additional check in case of update/delete action. The additional check is to ensure that the annotation really exists on hypothesis: https://gitlab.coko.foundation/kotahi/kotahi/-/blob/57fb44d4b60e8cd94f1ac1af096d713d250c3832/server/publishing/hypothesis/index.js#L102-111
We make an axios
get request to fetch the resource from the annotation ID. The problem was that headers for the axios request were not set correctly and it was result in a 404
, causing the action to be changed to create
(inside the catch
block) and hence a annotation for the same field was getting created.
Fix
Just spread the headers
before making the axios call (like it is done elsewhere in the file).