Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const http = (function () {
- const send = (url, method, body) => {
- const payload = {
- headers: {
- "Content-Type": "application/json",
- },
- method,
- body: JSON.stringify(body)
- };
- return fetch(url, payload)
- .then(response =>{
- console.log(response.json());
- response.json()
- } );
- };
- const post = (url, body) => send(url, 'POST', body);
- const get = (url) => send(url, 'GET', null);
- return {send, post, get};
- }());
- $("#logout").on('click', (ev) => {
- http.post("/users/logout")
- .then(() => {window.location = '/users/login?logout'});
- ev.preventDefault();
- return false;
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement