Gennadysht 1 rok temu
rodzic
commit
1cc1c4368c
2 zmienionych plików z 19 dodań i 1 usunięć
  1. 14 0
      .vscode/launch.json
  2. 5 1
      src/utills/utils.js

+ 14 - 0
.vscode/launch.json

@@ -4,6 +4,20 @@
     // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
     "version": "0.2.0",
     "configurations": [
+        {
+            "type": "vscode-edge-devtools.debug",
+            "request": "attach",
+            "name": "Attach to Microsoft Edge and open the Edge DevTools",
+            "url": "http://localhost:3000",
+            "webRoot": "${workspaceFolder}"
+        },
+    {
+        "type": "vscode-edge-devtools.debug",
+        "request": "launch",
+        "name": "Launch Microsoft Edge and open the Edge DevTools",
+        "url": "http://localhost:3000",
+        "webRoot": "${workspaceFolder}"
+    },
         {
             "type": "chrome",
             "request": "launch",

+ 5 - 1
src/utills/utils.js

@@ -13,7 +13,11 @@ const findObjectIndexById = (objs, goodId) => {
 function saveImage(image) {
     let formData = new FormData();
     formData.append('photo', image.data);
-    let token = JSON.parse(JSON.parse(localStorage["persist:auth"]).token);
+    let token = "";
+    if (localStorage["persist:auth"])
+        token = JSON.parse(JSON.parse(localStorage["persist:auth"]).token);
+    else
+        token = JSON.parse(JSON.parse(localStorage["persist:root"]).auth).token;
     let res = fetch(getFullBackendUrl('/upload'), {
         method: "POST",
         headers: token ? { Authorization: 'Bearer ' + token } : {},