我目前正在用Vue.js构建我的前端,我的API是用Slim构建的。在我的所有页面中,只需要一个API就可以执行,没有任何错误。
我正在处理的当前页面要求2API将调用到localhost/api/events和localhost/api/events/68/results。我的Vue前端坐在localhost:8080。
在其他页面上单独执行API请求可以正常工作。在Postman中单独执行API请求很好。在Postman中对这两个API调用执行许多迭代都很好。
在我的Vuex商店(getEvents / getResults)中都调用了相同的操作
,但通过Axios从我的前端执行两个API调用--一个或两个都随机失败--.
500 Internal Server Error
Object { type: "Illuminate\\Database\\QueryException", code: 0, message: "Database hosts array is empty. (SQL: select * from `events` where `events`.`id` = 68 limit 1)", … }
...
message "Database hosts array is empty. (SQL: select * from `events` where `events`.`id` = 68 limit 1)"发布于 2021-01-26 23:39:25
看起来您正在使用.env文件作为数据库凭据。问题是这不是线程安全的,不应该在生产中使用。这是一个众所周知的问题。最好使用env.php文件来解决这个问题。
https://stackoverflow.com/questions/65910697
复制相似问题