Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

add transformReponse function #130

Open
wants to merge 1 commit into
base: devel
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
5 changes: 5 additions & 0 deletions packages/rest/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Meteor.publish = function (name, handler, options) {
'url',
'getArgsFromRequest',
'httpMethod',
'transformResponse',
];

var httpOptions = _.pick(options, httpOptionKeys);
Expand All @@ -57,6 +58,9 @@ Meteor.publish = function (name, handler, options) {
url: 'publications/' + name,
getArgsFromRequest: defaultGetArgsFromRequest,
httpMethod: 'get',
transformResponse: function(response) {
return response;
}
});

JsonRoutes.add(httpOptions.httpMethod, httpOptions.url, function (req, res) {
Expand All @@ -68,6 +72,7 @@ Meteor.publish = function (name, handler, options) {
});

httpSubscription.on('ready', function (response) {
response = httpOptions.transformResponse(response);
JsonRoutes.sendResult(res, {data: response});
});

Expand Down