]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - assets/default/js/base.js
Merge pull request #1511 from ArthurHoaro/wip-slim-routing
[github/shaarli/Shaarli.git] / assets / default / js / base.js
index af3d650c3a66fcedce1345e85b950bedcc47b76c..0f29799d148d8f864ff009ef2f7034aa5bbf07c3 100644 (file)
@@ -26,11 +26,15 @@ function findParent(element, tagName, attributes) {
  * Ajax request to refresh the CSRF token.
  */
 function refreshToken(basePath) {
+  console.log('refresh');
   const xhr = new XMLHttpRequest();
-  xhr.open('GET', `${basePath}/?do=token`);
+  xhr.open('GET', `${basePath}/admin/token`);
   xhr.onload = () => {
-    const token = document.getElementById('token');
-    token.setAttribute('value', xhr.responseText);
+    const elements = document.querySelectorAll('input[name="token"]');
+    [...elements].forEach((element) => {
+      console.log(element);
+      element.setAttribute('value', xhr.responseText);
+    });
   };
   xhr.send();
 }