I'm having a little difficulty with implementing the game API code to do anything other than log-in, sign-up, log-out. I have some basic code to save and get games started, but am a little lost in how to access stored game information and saving game information.
Sample of my code in api.js . I acknowledge that the code may not be workable as is.
// create game
const createGame = function (data) {
console.log('data is ', data)
return $.ajax({
url: config.apiOrigin + '/games',
method: 'POST',
headers: {
Authorization: 'Token token=' + store.user.token
},
data
})
}
// save game
const saveGame = function (data) {
console.log('data is ', data)
return $.ajax({
url: config.apiOrigin + '/games/' + store.user.token,
method: 'PATCH',
headers: {
Authorization: 'Token token=' + store.user.token
},
data
})
}
// get game info
const showGame = function (data) {
console.log('data is ', data)
return $.ajax({
url: config.apiOrigin + '/games/' + store.user.token,
method: 'GET',
headers: {
Authorization: 'Token token=' + store.user.token
},
data
})
}
module.exports = {
signUp,
signIn,
signOut,
changePassword,
createGame,
saveGame,
showGame
}
I'm having a little difficulty with implementing the game API code to do anything other than log-in, sign-up, log-out. I have some basic code to save and get games started, but am a little lost in how to access stored game information and saving game information.
Sample of my code in api.js . I acknowledge that the code may not be workable as is.