Skip to content

Restrict API call query parameters to what we say we accept #653

Description

@stephenplusplus

Related: #647, #652

Right now, we sometimes kind of blindly pass the user's provided object to the API. We should be sure to only pass through what we say in our docs we accept.

I'm thinking something like:

/**
 * @param query.maxResults
 * @param query.pageSize
 */
Service.prototype.method = function(query, callback) {
  var allowedQueryParameters = ['maxResults', 'pageSize'];
  var requestQuery = util.pluck(query, allowedQueryParameters);
  // If `query` had more on it, we get a new object back with just the
  // params we want the API to receive.

  callApi('POST', '/path', requestQuery);
};

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions