diff --git a/README.md b/README.md index ee234bb..e12e68d 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ var sync = require("ampersand-sync") var rawRequest = sync(method, model, options) ``` -**method** is a string used for choosing HTTP verb of the sync request. It has to be chosen from the keys of the following map: +**method** is a string used for choosing HTTP verb of the sync request. You can either provide the HTTP method you want to use directly (GET, POST, etc) or specify a RESTful operation which will apply the following convention (used by `ampersand-model`): ```js { 'create': 'POST', diff --git a/core.js b/core.js index 22486b7..9531741 100644 --- a/core.js +++ b/core.js @@ -27,7 +27,7 @@ module.exports = function (xhr) { //Copy the options object. It's using assign instead of clonedeep as an optimization. //The only object we could expect in options is headers, which is safely transfered below. var options = assign({},optionsInput); - var type = methodMap[method]; + var type = methodMap[method] || method; var headers = {}; // Default options, unless specified. @@ -66,7 +66,7 @@ module.exports = function (xhr) { } // Ensure that we have the appropriate request data. - if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) { + if (options.data == null && model && (type === 'POST' || type === 'PUT' || type === 'PATCH')) { params.json = options.attrs || model.toJSON(options); }