Created
May 1, 2016 07:15
-
-
Save jeffhollan/ef4be9bdef60801d96f53a502dc12a0d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function (context, data) { | |
context.res = { | |
body: parseQuery(data.form) | |
}; | |
context.done(); | |
}; | |
function parseQuery(qstr) { | |
var query = {}; | |
var a = qstr.substr(0).split('&'); | |
for (var i = 0; i < a.length; i++) { | |
var b = a[i].split('='); | |
query[decodeURIComponent(b[0])] = decodeURIComponent(b[1] || '').replace(new RegExp("\\+", 'g'), ' '); | |
} | |
return query; | |
} |
Edit the function.json
file and add "dataType": "stream"
to the incoming binding, like this:
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"dataType": "stream"
},
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I keep getting this error:
mscorlib: TypeError: Cannot read property 'substr' of undefined
at parseQuery