Skip to content

Commit

Permalink
добавил сохранение JWT в localStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
veglem committed Mar 4, 2024
1 parent a580204 commit 9d02110
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions public/src/modules/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const methods = {

let JWT = null

JWT = window.localStorage.getItem('Authorization')

const baseRequest = async (method, url, data = null) => {
const options = {
method: method,
Expand Down Expand Up @@ -36,12 +38,9 @@ const baseRequest = async (method, url, data = null) => {
} catch (err) {
console.log("no body")
}
for (const header of response.headers) {
console.log(header)
}
if (response.headers.get('Authorization') !== null) {
JWT = response.headers.get('Authorization');
console.log(JWT)
window.localStorage.setItem('Authorization', JWT)
}
return {status: response.status, body}
} catch (err) {
Expand Down

0 comments on commit 9d02110

Please sign in to comment.