首页 > 解决方案 > Feathers js - 不能在地图功能中抛出错误

问题描述

/test当我使用 Postman向端点发送请求时,

我预计 在此处输入图像描述

但相反,它仅在控制台上显示错误并且请求成功

Console:

error: same result is here! {"type":"FeathersError","name":"Conflict","code":409,"className":"conflict","errors":{}}

测试钩子.js

const errors = require('@feathersjs/errors');

module.exports = {
  before: {
    all: [],
    find: [
      async context=>{
        if(xxxx){
          if(xxx){
             data.map(x => {
                throw new errors.Conflict('same result is here!')
             })
          }
        }
      }
    ],
    ...
  },

  after: {
   ...
  },
  error: {
   ...
  }
};

标签: javascriptnode.jsfeathersjs

解决方案


推荐阅读