{"action":"created","issue":{"url":"https://api.github.com/repos/awslabs/aws-serverless-express/issues/145","repository_url":"https://api.github.com/repos/awslabs/aws-serverless-express","labels_url":"https://api.github.com/repos/awslabs/aws-serverless-express/issues/145/labels{/name}","comments_url":"https://api.github.com/repos/awslabs/aws-serverless-express/issues/145/comments","events_url":"https://api.github.com/repos/awslabs/aws-serverless-express/issues/145/events","html_url":"https://github.com/awslabs/aws-serverless-express/issues/145","id":322940186,"number":145,"title":"POST Comes In As GET","user":{"login":"JimTheMan","id":5354163,"avatar_url":"https://avatars2.githubusercontent.com/u/5354163?v=4","gravatar_id":"","url":"https://api.github.com/users/JimTheMan","html_url":"https://github.com/JimTheMan","followers_url":"https://api.github.com/users/JimTheMan/followers","following_url":"https://api.github.com/users/JimTheMan/following{/other_user}","gists_url":"https://api.github.com/users/JimTheMan/gists{/gist_id}","starred_url":"https://api.github.com/users/JimTheMan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JimTheMan/subscriptions","organizations_url":"https://api.github.com/users/JimTheMan/orgs","repos_url":"https://api.github.com/users/JimTheMan/repos","events_url":"https://api.github.com/users/JimTheMan/events{/privacy}","received_events_url":"https://api.github.com/users/JimTheMan/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2018-05-14T18:59:54Z","updated_at":"2018-05-15T23:26:46Z","closed_at":"2018-05-15T16:12:01Z","author_association":"NONE","body":"Hi, whenever I send an ajax POST request like this:\r\n\r\n```\r\n$.ajax({\r\n\t\t\turl: \t\toptions.url,\r\n\t\t\tdataType: \t'json',\r\n\t\t\tcrossDomain: true,\r\n\t\t\tcontentType: \"application/json\",\r\n\t\t\ttype:\t\t\"POST\",\r\n\t\t\tdata:\t\toptions.params,\r\n\t\t\tsuccess: \tfunction(data){\r\n\t\t\t\t// Apply the ajax-after plugins: Modifying the ajax response\r\n\t\t\t\t_.each(scope.plugins['ajax-after'], function(callback) {\r\n\t\t\t\t\tdata\t= callback(data, options.params);\r\n\t\t\t\t});\r\n\t\t\t\toptions.callback(data);\r\n\t\t\t\tconsole.log('@@@, ', data)\r\n\t\t\t},\r\n\t\t\terror: function(jqXHR, data, errorThrown) {\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t});\r\n```\r\n\r\nThe request is handled by my lambda function as a GET request.\r\n\r\n```\r\nconst awsServerlessExpressMiddleware = require('aws-serverless-express/middleware')\r\nconst userEmbed = require('./src/user-embed')\r\nconst bodyParser = require('body-parser')\r\nconst express = require('express')\r\nconst app = express()\r\napp.use(express.urlencoded({extended: true}))\r\napp.use(bodyParser.json())\r\napp.use(awsServerlessExpressMiddleware.eventContext())\r\n\r\n// Allows supertest e2e tests to override the apiGateway event object.\r\napp.inputObjectOverride = { uuids: '' }\r\n\r\napp.get('/', function(req, res) {\r\n\r\n\tlet args = app.inputObjectOverride\r\n\r\n  if (req.apiGateway)\r\n    args = req.apiGateway.event.queryStringParameters || req.apiGateway.event\r\n\r\n    console.log('get args: ', args)\r\n\r\n\treturn userEmbed.handleIncomingUuidsOrUuid(args.uuids).then(result => {\r\n\r\n\t  console.log('Returning Get result! ', result);\r\n\t\tres.send(result)\r\n\t}, error => {\r\n\t\tres.send(error)\r\n    })\r\n})\r\n\r\nvar urlencodedParser = bodyParser.urlencoded({ extended: false })\r\n\r\napp.post('/', function(req, res) {\r\n  let args = app.inputObjectOverride\r\n\r\n  if (req.apiGateway)\r\n    args = req.apiGateway.event.queryStringParameters || req.apiGateway.event\r\n\r\n  console.log('post args: ', args)\r\n\r\n  return userEmbed.handleIncomingUuidsOrUuid(args.uuids).then(result => {\r\n\r\n    console.log('Returning Post result! ', result)\r\n    res.send(result)\r\n  }, error => {\r\n    res.send(error)\r\n  })\r\n})\r\n\r\nmodule.exports = app\r\n```\r\n\r\nThe log shows \"get args:\" and \"Returning Get result!\". Is this intentional? Why is it being handled by `app.get` instead of `app.post`?\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/awslabs/aws-serverless-express/issues/comments/389346018","html_url":"https://github.com/awslabs/aws-serverless-express/issues/145#issuecomment-389346018","issue_url":"https://api.github.com/repos/awslabs/aws-serverless-express/issues/145","id":389346018,"user":{"login":"JimTheMan","id":5354163,"avatar_url":"https://avatars2.githubusercontent.com/u/5354163?v=4","gravatar_id":"","url":"https://api.github.com/users/JimTheMan","html_url":"https://github.com/JimTheMan","followers_url":"https://api.github.com/users/JimTheMan/followers","following_url":"https://api.github.com/users/JimTheMan/following{/other_user}","gists_url":"https://api.github.com/users/JimTheMan/gists{/gist_id}","starred_url":"https://api.github.com/users/JimTheMan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JimTheMan/subscriptions","organizations_url":"https://api.github.com/users/JimTheMan/orgs","repos_url":"https://api.github.com/users/JimTheMan/repos","events_url":"https://api.github.com/users/JimTheMan/events{/privacy}","received_events_url":"https://api.github.com/users/JimTheMan/received_events","type":"User","site_admin":false},"created_at":"2018-05-15T23:26:46Z","updated_at":"2018-05-15T23:26:46Z","author_association":"NONE","body":"Ok, thanks Brett. I was able to get it working by following the project on this repo's example folder, but I already had those libraries in my project so I'm still confused as to my my old version didn't work... is the order of the \"app.use\" statements very important?\r\n\r\nAlso, I had to remove the \"compression\" lib. When I had this in there the code would get all the way down to \"res.send\", but it wouldn't actually give me a response. Any idea why this is would be happening? The data in trying to return in an array containing one \"medium\" sized object. "}}
{"actor":{"display_login":"JimTheMan"}}