Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for POST requests on the importer #191

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/importers/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* extract - a method to pass raw data through before handing back to parser.
* dataType - ajax datatype
* jsonp - true if it's a jsonp request, false otherwise.
* type - wether to do a post or a get request (defaults to 'GET')
* data - The post data to send with the request
*/
Dataset.Importers.Remote = function(options) {
options = options || {};
Expand All @@ -20,11 +22,18 @@

// Default ajax request parameters
this.params = {
type : "GET",
type : "GET", // if you define type, otherwise "get"
url : _.isFunction(this._url) ? _.bind(this._url, this) : this._url,
dataType : options.dataType ? options.dataType : (options.jsonp ? "jsonp" : "json"),
callback : options.callback
};

// support for POST requests, just define them here.
if (options.hasOwnProperty('data') && options.hasOwnProperty('type')) {
this.params.type = options.type;
this.params.data = options.data;
}

};

_.extend(Dataset.Importers.Remote.prototype, Dataset.Importers.prototype, {
Expand Down