{"action":"created","issue":{"url":"https://api.github.com/repos/ga-wdi-boston/group-project/issues/112","repository_url":"https://api.github.com/repos/ga-wdi-boston/group-project","labels_url":"https://api.github.com/repos/ga-wdi-boston/group-project/issues/112/labels{/name}","comments_url":"https://api.github.com/repos/ga-wdi-boston/group-project/issues/112/comments","events_url":"https://api.github.com/repos/ga-wdi-boston/group-project/issues/112/events","html_url":"https://github.com/ga-wdi-boston/group-project/issues/112","id":155046649,"number":112,"title":"My GET ajax call is resulting in a empty req body","user":{"login":"louarnos","id":17519351,"avatar_url":"https://avatars.githubusercontent.com/u/17519351?v=3","gravatar_id":"","url":"https://api.github.com/users/louarnos","html_url":"https://github.com/louarnos","followers_url":"https://api.github.com/users/louarnos/followers","following_url":"https://api.github.com/users/louarnos/following{/other_user}","gists_url":"https://api.github.com/users/louarnos/gists{/gist_id}","starred_url":"https://api.github.com/users/louarnos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/louarnos/subscriptions","organizations_url":"https://api.github.com/users/louarnos/orgs","repos_url":"https://api.github.com/users/louarnos/repos","events_url":"https://api.github.com/users/louarnos/events{/privacy}","received_events_url":"https://api.github.com/users/louarnos/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-16T14:53:58Z","updated_at":"2016-05-16T15:15:46Z","closed_at":"2016-05-16T15:15:46Z","body":"my index action is:\r\n\r\n```\r\n'use strict';\r\n\r\nconst controller = require('lib/wiring/controller');\r\nconst models = require('app/models');\r\nconst User = models.user;\r\nconst Location = models.location;\r\n\r\nconst authenticate = require('./concerns/authenticate');\r\n\r\nconst index = (req, res, next) => {\r\n  console.log(req.body);\r\n  User.findById(req.body.user.id).then (function(user){\r\n    console.log(user);\r\n    let locations = user.locations;\r\n    return locations;\r\n  })\r\n  .then(locations => res.json({ locations }))\r\n  .catch(err => next(err));\r\n};\r\n```\r\n\r\nmy ajax call is : \r\n```\r\n'use strict';\r\n\r\nconst app = require('../app-data.js');\r\n\r\nconst getUserLocations = (success, failure, user_id) => {\r\n  $.ajax({\r\n    method: 'GET',\r\n    url: app.api + '/locations/',\r\n    data: {\r\n      user: {\r\n        id: user_id,\r\n      }\r\n    },\r\n    headers: {\r\n    \"Content-Type\": \"application/json\",\r\n  },\r\n  }).done(success)\r\n    .fail(failure)\r\n};\r\n```\r\nThe console log in the index action results in an empty body despite me defining data in the ajax call. I dont know if maybe a GET request is assumed to have no data and is therefore stripped.\r\n\r\nI get what I would expect with the following curl request:\r\n\r\n```\r\ncurl --include --request GET http://localhost:3000/locations/ \\\r\n  --header \"Content-Type: application/json\" \\\r\n  --data '{\r\n    \"user\": {\r\n      \"id\": \"57367b0041aca8458585a139\"\r\n    }\r\n  }'\r\n```"},"comment":{"url":"https://api.github.com/repos/ga-wdi-boston/group-project/issues/comments/219452108","html_url":"https://github.com/ga-wdi-boston/group-project/issues/112#issuecomment-219452108","issue_url":"https://api.github.com/repos/ga-wdi-boston/group-project/issues/112","id":219452108,"user":{"login":"louarnos","id":17519351,"avatar_url":"https://avatars.githubusercontent.com/u/17519351?v=3","gravatar_id":"","url":"https://api.github.com/users/louarnos","html_url":"https://github.com/louarnos","followers_url":"https://api.github.com/users/louarnos/followers","following_url":"https://api.github.com/users/louarnos/following{/other_user}","gists_url":"https://api.github.com/users/louarnos/gists{/gist_id}","starred_url":"https://api.github.com/users/louarnos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/louarnos/subscriptions","organizations_url":"https://api.github.com/users/louarnos/orgs","repos_url":"https://api.github.com/users/louarnos/repos","events_url":"https://api.github.com/users/louarnos/events{/privacy}","received_events_url":"https://api.github.com/users/louarnos/received_events","type":"User","site_admin":false},"created_at":"2016-05-16T15:15:46Z","updated_at":"2016-05-16T15:15:46Z","body":"We wanted to have a method to get any users locations by id so we can have current user follow other users and see their locations. GET requests by nature do not have a body, so our solution was to build a custom controller method that used a query string to pass in the user_id. This require reworking my ajax call to:\r\n\r\n```\r\nconst getUserLocations = (success, failure, user_id) => {\r\n  $.ajax({\r\n    method: 'GET',\r\n    url: app.api + '/user_locations?user_id=' + user_id,\r\n    headers: {\r\n    \"Content-Type\": \"application/json\",\r\n  },\r\n  }).done(success)\r\n    .fail(failure)\r\n};\r\n```\r\nOur custom controller action looks like:\r\n\r\n```\r\nconst indexUserLocations = (req, res, next) => {\r\n  User.findById(req.query.user_id).then (function(user){\r\n    let locations = user.locations;\r\n    return locations;\r\n  })\r\n  .then(locations => res.json({ locations }))\r\n  .catch(err => next(err));\r\n};\r\n```"}}