Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffhollan/ef4be9bdef60801d96f53a502dc12a0d to your computer and use it in GitHub Desktop.
Save jeffhollan/ef4be9bdef60801d96f53a502dc12a0d to your computer and use it in GitHub Desktop.
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;
}
@MPSolanki
Copy link

I keep getting this error:

mscorlib: TypeError: Cannot read property 'substr' of undefined
at parseQuery

@DavidCannon
Copy link

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