[英]Exception 'TypeError: Object prototype may only be an Object or null' running dyson mock server (using express.js)
Running the webpro/dyson-demo (node.js) as a mock server and attempted to return a canned data, for example: 将webpro / dyson-demo(node.js)作为模拟服务器运行,并尝试返回罐装数据,例如:
module.exports = {
path: '/query?',
collection: false,
template: function(params, query, body, cookies, headers) {
return cannedJsonFromFile;
},
}; };
But received the error message (dyson uses Express.js): 但是收到了错误消息(戴森使用Express.js):
"Potentially unhandled rejection [1] TypeError: Object prototype may only be an Object or null: ..." (bottom of stack): at c:\\dev\\projects\\noms\\navmps.services.demo\\dyson-mock-oob-server\\dyson-demo\\node_modules\\dyson\\lib\\response.js:82:53 “可能未处理的拒绝[1] TypeError:对象原型只能是对象或null:...”(堆栈底部):位于c:\\ dev \\ projects \\ noms \\ navmps.services.demo \\ dyson-mock-oob -server \\戴森-演示\\ node_modules \\戴森\\ lib中\\ response.js:82:53
The canned data was loaded as a JSON string '{...}' and needed to be converted to a an object using JSON.parse: 罐装数据已作为JSON字符串“ {...}”加载,需要使用JSON.parse转换为对象:
module.exports = {
path: '/query?',
collection: false,
template: function(params, query, body, cookies, headers) {
return JSON.parse(cannedJsonFromFile);
},
}; };
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.