Created
January 20, 2017 03:11
-
-
Save BenGitsCode/4e1bdee257cd0cfd727cefb7717030db to your computer and use it in GitHub Desktop.
Scaffold Sample user AJAX requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const app = require('../app-data'); | |
const signIn = (success, failure, data) => { | |
$.ajax({ | |
method: "POST", | |
url: app.server.api + '/sign-in', | |
data, | |
}) | |
.done(success, data) | |
.fail(failure); | |
}; | |
const signUp = (success, failure, data) => { | |
$.ajax({ | |
method: "POST", | |
url: app.server.api + '/sign-up', | |
data, | |
}) | |
.done(success, data) | |
.fail(failure); | |
}; | |
const signOut = (success, failure, data) => { | |
$.ajax({ | |
method: "DELETE", | |
url: app.server.api + '/sign-out/' + app.currentUser.id, | |
data, | |
headers: { | |
Authorization: 'Token token='+ app.currentUser.token, | |
}, | |
}) | |
.done(success) | |
.fail(failure); | |
}; | |
const changePass = (success, failure, data) => { | |
// if (!app.currentUser) bad; | |
$.ajax({ | |
method: "PATCH", | |
url: app.server.api + '/change-password/' + app.currentUser.id, | |
data, | |
headers: { | |
Authorization: 'Token token='+ app.currentUser.token, | |
}, | |
}) | |
.done(success) | |
.fail(failure); | |
}; | |
module.exports = { | |
signUp, | |
signIn, | |
signOut, | |
changePass, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment