Node.js 环回Post API消费请求正文

Node.js 环回Post API消费请求正文,node.js,loopbackjs,loopback,Node.js,Loopbackjs,Loopback,我有以下模型,它应该使用post API中的消息: 'use strict'; module.exports = function (Message) { Message.hl7_message = function (cb) { cb(null, 'Success... '); } Message.remoteMethod( 'hl7_message', { http: {

我有以下模型,它应该使用post API中的消息:

'use strict';

module.exports = function (Message) {


    Message.hl7_message = function (cb) {


        cb(null, 'Success... ');
    }

    Message.remoteMethod(
            'hl7_message', {
                http: {
                    path: '/hl7_message',
                    verb: 'post',
                    status: 200,
                    errorStatus: 400
                },
                accepts: [],
                returns: {
                    arg: 'status',
                    type: 'string'
                }
            }
    );




};
但是,发布的数据没有预定义的参数,而是作为一个原始的主体,内容类型为:Application/JSON格式

我如何配置hl7_消息post consumer以获取发布值的主体? e、 g要求主体

例如,将整个请求正文作为值的参数:

{arg:'data',type:'object',http:{source:'body'}

您可以将上述行添加到远程方法描述中的
accepts
数组中,并向函数本身添加一个额外的参数(
data

Message.hl7_message = function (data, cb) {
    console.log('my request body: ' + JSON.stringify(data));
    cb(null, 'Success... ');
}

Message.remoteMethod(
        'hl7_message', {
            http: {
                path: '/hl7_message',
                verb: 'post',
                status: 200,
                errorStatus: 400
            },
            accepts: [{ arg: 'data', type: 'object', http: { source: 'body' } },
            returns: {
                arg: 'status',
                type: 'string'
            }
        }
);