我使用以下方式导入了 restivus:
meteor add nimble:restivus
在使用 Restivus 时,我在 Meteor 启动时遇到此错误:
"Cannot find name 'Restivus' ".
虽然我可以获取请求,但我想知道它是否会影响应用程序的行为。
这是使用的代码:
if (Meteor.isServer) {
// Global API configuration
var Api = new Restivus({
apiPath: 'api/',
prettyJson: true
});
}
接收 POST 时,我的 request.body 和 bodyParams 为空:
Api.addRoute(':id/test', {
post: function () {
var id = this.urlParams.id;
console.log("Body contains : ");
console.log(this.bodyParams);
return {
status: 'success',
url : 'post test from id: '+id,
body : this.bodyParams
};
}
});
有谁知道如何使此错误消失以及这是否与 POST 正文问题有关?
最佳答案
如果您使用 Meteor 1.4+,您可以尝试使用如下内容将 Restivus 导入到您的文件中:
import Restivus from 'nibmle:restivus';
关于meteor - 实例化 Restivus 时出错 "Cannot find name ' Restivus' ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42086317/