starts improving REST Api
This commit is contained in:
@@ -18,13 +18,29 @@ export const Api = {
|
||||
return fetch(API_ENDPOINT(playerId + "/loot"))
|
||||
.then(r => r.json())
|
||||
},
|
||||
putClaim (playerId, itemId) {
|
||||
return fetch(API_ENDPOINT(playerId + "/claim/" + itemId))
|
||||
.then(r => r.json())
|
||||
putClaim (player_id, item_id) {
|
||||
const payload = { player_id, item_id };
|
||||
return fetch(API_ENDPOINT("claims"),
|
||||
{
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(payload)
|
||||
})
|
||||
.then(r => r.json())
|
||||
},
|
||||
unClaim (playerId, itemId) {
|
||||
return fetch(API_ENDPOINT(playerId + "/unclaim/" + itemId))
|
||||
.then(r => r.json())
|
||||
unClaim (player_id, item_id) {
|
||||
const payload = { player_id, item_id };
|
||||
return fetch(API_ENDPOINT("claims"),
|
||||
{
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(payload)
|
||||
})
|
||||
.then(r => r.json())
|
||||
},
|
||||
updateWealth (playerId, goldValue) {
|
||||
return fetch(API_ENDPOINT(playerId + "/update-wealth/" + goldValue))
|
||||
@@ -83,7 +99,7 @@ export const AppStorage = {
|
||||
// Sets a new active player by id
|
||||
setActivePlayer (newPlayerId) {
|
||||
if (this.debug) console.log('setActivePlayer to ', newPlayerId)
|
||||
this.state.player_id = newPlayerId
|
||||
this.state.player_id = Number(newPlayerId)
|
||||
document.cookie = `player_id=${newPlayerId};`;
|
||||
},
|
||||
// Show/Hide player's chest
|
||||
|
||||
Reference in New Issue
Block a user