gpt4 book ai didi

javascript - TypeError : exits. 成功不是函数

转载 作者:行者123 更新时间:2023-11-29 23:04:44 25 4
gpt4 key购买 nike

<分区>

我正在尝试弄清楚如何将 Sails.js 与 Node 机器语法一起使用。这是我的航类列表操作,简单,没有什么疯狂的。我正在尝试这个:

/**
* FlightsController
*
* @description :: Server-side actions for handling incoming requests.
* @help :: See https://sailsjs.com/docs/concepts/actions
*/

module.exports = {

friendlyName: 'flights list',


description: 'list all flights',

exits: {
success: {
responseType: 'view',
viewTemplatePath: 'pages/list'
},
notFound: {
description: 'No flight was found in the database.',
responseType: 'notFound'
}
},

fn: async function (exits) {

var flights = await Flights.find({});

// If no flight was found, respond "notFound" (like calling `res.notFound()`)
if (!flights) { return exits.notFound(); }

// Display the hompage view.
return exits.success({flights});
}
};

但是当我尝试访问页面/list 时,它向我显示了 500 服务器错误页面,其中包含以下消息:“TypeError: exits.success is not a function”。我真的不明白,因为那是要你使用的语法。它缺少“输入”对象,但我删除了它,因为我真的不需要它,只是想在我的数据存储中输出航类。它似乎并没有解决问题。

有什么想法吗?谢谢你!

我的飞行模型是这样的:

module.exports = {

attributes: {
company:{
type: 'string',
required: true
},
takeoff:{
type: 'string',
required: false
}
},

};

我的页面 list.ejs 字面上显示“LIST”这个词,就像那样。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com