尝试根据Axois POST请求发送一个错误对象,在服务器上获取一个空对象

时间:2019-10-10 08:23:49

标签: javascript node.js vue.js post axios

大家好,我正在为前端错误构建日志记录微服务。 所以我想这样在我的日志中查看所有的Erros

catch(err){
 sendToLogs({message: 'Could not read input', error: err})
}

然后

sendToLogger: (payload) => {
try {

axios({
  method: 'post',
  url: 'config.loggingUrl',
  data: payload,
  headers: {'Content-Type': 'application/json'}
});

  }
} catch (err) {
}}

但是在Logging服务器上,对象看起来像

{message: 'Could not read input', error: {} }

1 个答案:

答案 0 :(得分:0)

我认为您应该使用调试代码。原因有很多,也许变量payload没用