{"action":"opened","issue":{"url":"https://api.github.com/repos/ga-wdi-boston/game-project/issues/669","repository_url":"https://api.github.com/repos/ga-wdi-boston/game-project","labels_url":"https://api.github.com/repos/ga-wdi-boston/game-project/issues/669/labels{/name}","comments_url":"https://api.github.com/repos/ga-wdi-boston/game-project/issues/669/comments","events_url":"https://api.github.com/repos/ga-wdi-boston/game-project/issues/669/events","html_url":"https://github.com/ga-wdi-boston/game-project/issues/669","id":222008556,"number":669,"title":"Passing in Data w/ Patch","user":{"login":"andyjzhong","id":26101294,"avatar_url":"https://avatars2.githubusercontent.com/u/26101294?v=3","gravatar_id":"","url":"https://api.github.com/users/andyjzhong","html_url":"https://github.com/andyjzhong","followers_url":"https://api.github.com/users/andyjzhong/followers","following_url":"https://api.github.com/users/andyjzhong/following{/other_user}","gists_url":"https://api.github.com/users/andyjzhong/gists{/gist_id}","starred_url":"https://api.github.com/users/andyjzhong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyjzhong/subscriptions","organizations_url":"https://api.github.com/users/andyjzhong/orgs","repos_url":"https://api.github.com/users/andyjzhong/repos","events_url":"https://api.github.com/users/andyjzhong/events{/privacy}","received_events_url":"https://api.github.com/users/andyjzhong/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-04-16T12:46:27Z","updated_at":"2017-04-16T12:46:27Z","closed_at":null,"body":"Greetings -- I'm currently stuck on figuring out how to pass in data to the game objects. More specifically, I've managed to successfully create a game in the Game API but I can't figure out how to get it so that when a user places an X on the game board, it logs the X into the current game id.\r\n\r\nI've tried reviewing open/closed issue logs and also the Game Project API documentation and understand that I have to pass in data using PATCH with something like this: \r\n```js\r\n{\r\n  \"game\": {\r\n    \"cell\": {\r\n      \"index\": 0,\r\n      \"value\": \"x\"\r\n    },\r\n    \"over\": false\r\n  }\r\n}\r\n```\r\n\r\nBelow is my code for updating a game:\r\n\r\nevents.js\r\n```js\r\nconst onUpdateGame = function (event) {\r\n  event.preventDefault()\r\n  console.log('AZ: onUpdateGame from events.js ran!')\r\n  const data = getFormFields(event.target)\r\n  console.log(data)\r\n  api.updateGame(data)\r\n    .then(ui.updateGameSuccess)\r\n    .catch(ui.updateGameFailure)\r\n}\r\n```\r\n\r\napi.js\r\n```js\r\n// Creates the Ajax function to PATCHES data into a game id\r\nconst updateGame = (id) => {\r\n  console.log('AZ: updateGame from api.js ran!')\r\n  console.log(id)\r\n  return $.ajax({\r\n    url: config.apiOrigin + '/games/' + store.game.id,\r\n    method: 'PATCH',\r\n    headers: {\r\n      Authorization: 'Token token=' + store.user.token\r\n    },\r\n    data: data\r\n  })\r\n}\r\n```\r\n\r\nui.js\r\n```js\r\nconst updateGameSuccess = (id) => {\r\n  console.log('AZ: updateGameSuccess from ui.js ran!')\r\n  console.log(id)\r\n  store.games = id.games\r\n}\r\n\r\nconst updateGameFailure = (error) => {\r\n  console.error(error)\r\n}\r\n```\r\n\r\nPlease let me know if you require any additional detail. Any guidance is greatly appreciated!"}}
{"actor":{"display_login":"andyjzhong"}}