{"action":"created","issue":{"url":"https://api.github.com/repos/webpro/dyson/issues/74","repository_url":"https://api.github.com/repos/webpro/dyson","labels_url":"https://api.github.com/repos/webpro/dyson/issues/74/labels{/name}","comments_url":"https://api.github.com/repos/webpro/dyson/issues/74/comments","events_url":"https://api.github.com/repos/webpro/dyson/issues/74/events","html_url":"https://github.com/webpro/dyson/issues/74","id":196104462,"number":74,"title":"Can I do a post request to a url and update a variable stored on the fake server?","user":{"login":"sensorhound-nan","id":22329811,"avatar_url":"https://avatars.githubusercontent.com/u/22329811?v=3","gravatar_id":"","url":"https://api.github.com/users/sensorhound-nan","html_url":"https://github.com/sensorhound-nan","followers_url":"https://api.github.com/users/sensorhound-nan/followers","following_url":"https://api.github.com/users/sensorhound-nan/following{/other_user}","gists_url":"https://api.github.com/users/sensorhound-nan/gists{/gist_id}","starred_url":"https://api.github.com/users/sensorhound-nan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sensorhound-nan/subscriptions","organizations_url":"https://api.github.com/users/sensorhound-nan/orgs","repos_url":"https://api.github.com/users/sensorhound-nan/repos","events_url":"https://api.github.com/users/sensorhound-nan/events{/privacy}","received_events_url":"https://api.github.com/users/sensorhound-nan/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-16T16:53:13Z","updated_at":"2017-02-01T10:10:53Z","closed_at":"2017-02-01T10:10:53Z","body":"I want to update the output I get from a  \"GET\" request. so I do a \"POST\" request before it.\r\nThe code I set up the fake server is like this:\r\n`\r\nvar data;\r\n\r\nvar generateResponse = function(req, res, next) {\r\n\tdata += req.body;\r\n    res.body = req.body;\r\n    next();\r\n};\r\n\r\nmodule.exports = {\r\n    path: '/dummy',\r\n    type: 'POST',\r\n    callback: generateResponse\r\n};\r\n`\r\n\r\n`\r\nvar data;\r\n\r\nmodule.exports = {\r\n\tpath: \"/dummy\",\r\n        type: \"GET\",\r\n\ttemplate: data\r\n}\r\n`\r\nBut the result of the \"GET\" request is the same before and after the \"POST\" request.\r\n\r\nI have also tried the set up the fake server's \"GET\" part like this:\r\n`\r\nmodule.exports = {\r\n\tpath: \"/dummy\",\r\n\ttemplate: data\r\n}\r\n`\r\nThen I will have the error:\r\n\"ReferenceError: data is not defined\"\r\n\r\nSo is there some suggestion to solve this problem. I am thinking of setting up a global variable shared by those two files and update the variable when I do a \"POST\" request. But I don't know how to do that. Someone help me please!"},"comment":{"url":"https://api.github.com/repos/webpro/dyson/issues/comments/276619606","html_url":"https://github.com/webpro/dyson/issues/74#issuecomment-276619606","issue_url":"https://api.github.com/repos/webpro/dyson/issues/74","id":276619606,"user":{"login":"webpro","id":456426,"avatar_url":"https://avatars.githubusercontent.com/u/456426?v=3","gravatar_id":"","url":"https://api.github.com/users/webpro","html_url":"https://github.com/webpro","followers_url":"https://api.github.com/users/webpro/followers","following_url":"https://api.github.com/users/webpro/following{/other_user}","gists_url":"https://api.github.com/users/webpro/gists{/gist_id}","starred_url":"https://api.github.com/users/webpro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webpro/subscriptions","organizations_url":"https://api.github.com/users/webpro/orgs","repos_url":"https://api.github.com/users/webpro/repos","events_url":"https://api.github.com/users/webpro/events{/privacy}","received_events_url":"https://api.github.com/users/webpro/received_events","type":"User","site_admin":false},"created_at":"2017-02-01T10:10:53Z","updated_at":"2017-02-01T10:10:53Z","body":"@gkohen Dyson is not an actual (storage) server, it's a basic stub server. Still, you can choose to store data as we discussed, or use another solution :-)"}}
{"actor":{"display_login":"webpro"}}