Try to fix the issues ABoss and Thomas were having with voting.
Specify credentials: "same-origin". This is the default option in the recent version of the spec, but in older versions it's "omit", which leads to cookies not getting sent and then the vote fails.
Change the VOTE_URL to be relative. This makes sure that the request is actually a "same-origin" request and credentials get sent.
Move error handling outside of the .then for JSON parsing, and add an alert to the .catch of JSON parsing. This way if KA returns "Unauthorized" (and JSON parsing fails), the user still gets feedback.
Try to fix the issues ABoss and Thomas were having with voting.
Specify
credentials: "same-origin"
. This is the default option in the recent version of the spec, but in older versions it's "omit", which leads to cookies not getting sent and then the vote fails. Change the VOTE_URL to be relative. This makes sure that the request is actually a "same-origin" request and credentials get sent. Move error handling outside of the .then for JSON parsing, and add an alert to the.catch
of JSON parsing. This way if KA returns "Unauthorized" (and JSON parsing fails), the user still gets feedback.(These commits can probably also be squashed.)