Skip to content

Commit

Permalink
Fetch request for deleting of expense set up
Browse files Browse the repository at this point in the history
  • Loading branch information
damienteo committed Mar 10, 2019
1 parent 3567ac7 commit a662234
Showing 1 changed file with 23 additions and 28 deletions.
51 changes: 23 additions & 28 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -744,43 +744,38 @@ class App extends React.Component {

handleDeleteExpense(id) {

// const {
// newExpense,
// newMonth,
// expenseReason,
// } = this.state;

let userId = cookies.get('userId');
let userSession = cookies.get('userSession');

const here = this;

let target_expense = {
id: parseInt(id),
userId: userId,
userSession: userSession
};

console.log("app", target_expense)

// let request = new Request(site + '/api/set-expense', {
// method: 'POST',
// headers: new Headers({
// 'Content-Type': 'application/json'
// }),
// body: JSON.stringify(user_expense)
// });

// //xmlhttprequest()

// fetch(request)
// .then(function (response) {
// response.json()
// .then(function (data) {
// here.setExpense(data.expenses[data.expenses.length - 1]);
// })
// })
// .catch(function (err) {
// console.log(err);
// })
let request = new Request(site + '/api/delete-expense', {
method: 'DELETE',
headers: new Headers({
'Content-Type': 'application/json'
}),
body: JSON.stringify(target_expense)
});

//xmlhttprequest()

fetch(request)
.then(function (response) {
response.json()
.then(function (data) {
console.log(data);
// here.deleteExpense(id);
})
})
.catch(function (err) {
console.log(err);
})
}

//================================================================================
Expand Down

0 comments on commit a662234

Please sign in to comment.