Skip to content

Commit

Permalink
fix: authorization on headers
Browse files Browse the repository at this point in the history
  • Loading branch information
delitamakanda authored Jul 7, 2020
1 parent 41cc3fe commit e3d66ff
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion frontend/src/api/BankApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'babel-polyfill';

import { csrftoken } from '../utils/cookie';

const API_HEADERS = {
let API_HEADERS = {
'Content-Type': 'application/json',
'X-CSRFToken': csrftoken,
// 'Authorization': 'Token ' + localStorage.token,
Expand Down Expand Up @@ -35,18 +35,22 @@ export default {
});
},
addAccount(userId, amountAccount) {
API_HEADERS['Authorization'] = 'Token ' + localStorage.token;
return fetch('/api/account/', {
method: 'post',
headers: API_HEADERS,
body: JSON.stringify({
user: userId,
balance: amountAccount
})
})
},
getAccount() {
API_HEADERS['Authorization'] = 'Token ' + localStorage.token;
return fetch('/api/account/', {headers: API_HEADERS})
},
getUser() {
API_HEADERS['Authorization'] = 'Token ' + localStorage.token;
return fetch('/api/users/i/', {headers: API_HEADERS})
}
}
Expand Down

0 comments on commit e3d66ff

Please sign in to comment.