我有一个数组
data = [38589, 3, __ob__: Observer];
Run Code Online (Sandbox Code Playgroud)
我想发送一个 put 请求 API,主体发送这个数组。并得到 400 错误?是不是这__ob__: Observer事是我的问题来发送这个数据?如果它是影响错误的那个,我能知道如何从我的数组中删除它吗?
我正在研究在 vue js 应用程序中使用 cognito 进行放大身份验证,以下是我在 main.js 中添加的代码:
import Amplify from 'aws-amplify';
Amplify.configure({
Auth: {
mandatorySignIn: false,
region: config.cognito.REGION,
userPoolId: config.cognito.USER_POOL_ID,
UserPoolClientId: config.cognito.APP_CLIENT_ID,
},
});
Run Code Online (Sandbox Code Playgroud)
但不知何故我收到了这种错误:
CognitoUserPool.js?17a7:46 Uncaught Error: Both UserPoolId and ClientId are required.
at new CognitoUserPool (CognitoUserPool.js?17a7:46)
at AuthClass.configure (Auth.js?bf82:183)
at eval (Amplify.js?7d03:83)
at Array.map (<anonymous>)
at AmplifyClass.configure (Amplify.js?7d03:82)
at eval (main.js?56d7:15)
at Module../src/main.js (app.js:1692)
at __webpack_require__ (app.js:854)
at fn (app.js:151)
at Object.1 (app.js:2809)
Run Code Online (Sandbox Code Playgroud)
我按照参考视频和 aws amplify 文档尝试了多种方法。但仍然发生相同的错误,我的页面是空白的,控制台中出现错误。检查了 Auth 选项,一切都很好。我该如何克服这个错误?我也没有使用任何客户端秘密哈希,因为 js sdk 无法与具有秘密哈希的应用程序客户端一起使用
我正在使用 Express 开发 Node.js 来构建后端。我打算处理可能发生的状态 500 错误。
router.put('/test', async (req, res) => {
try {
return res.send(await request.updateTest(req.body, 1))
} catch(err) {
console.log(err)
return res.status(500).send(err.stack)
}
})
Run Code Online (Sandbox Code Playgroud)
这是我的代码示例。它工作得很好。但是当我尝试从数据库查询中发出未知错误时,我想记录错误并返回状态 500 作为带有错误详细信息的响应。
但每次构建新的控制器/路由时我都需要添加 try 和 catch
无论如何,我可以以中间件的形式表达它们,而不是每次都写 try 和 catch 吗?
这是我尝试将其作为中间件的代码示例,但它在调用时不起作用且没有效果。
错误.js
module.exports = function (err, req, res, next) {
console.log(err)
res.status(500).send({
error: 'Internal Server Error',
message: err.stack
})
next(err)
}
Run Code Online (Sandbox Code Playgroud)
main.js
const errorHandler = require('./error')
const { corsOption } = require('./cors')
const cors = require('cors')
const test = require('./test')
module.exports …Run Code Online (Sandbox Code Playgroud)