mysql 使用react和node.js将数据插入数据库错误[关闭]

j9per5c4  于 5个月前  发布在  Mysql
关注(0)|答案(1)|浏览(60)

已关闭。此问题需要details or clarity。目前不接受回答。
**要改进此问题吗?**通过editing this post添加详细信息并阐明问题。

21天前关闭
Improve this question
我有一个问题。当我尝试将数据插入数据库时,它工作正常,通常页面不会刷新,但当我尝试上传图像时,图像上传但数据不会插入数据库,页面刷新(这不正常):
react.js:https://github.com/worldremo/Top_Gardering/blob/main/client/src/views/Home.jsx
node.js/express.js https://github.com/worldremo/Top_Gardering/blob/main/server/index.js

ccgok5k5

ccgok5k51#

你的问题可能是因为你以一种有点时髦的方式处理了finally部分。这就像一个无论游戏如何进行的备份团队,但似乎你传递setLoading(false)就像它是一个直接启动的球员,这可能会引起一些混乱。
所以,为了解决这个问题,你必须将setLoading(false) Package 在某种包中,就像一群朋友总是互相帮助一样。

useEffect(() => {
    axios.get('http://localhost:8080/postsapi')
        .then(response => { setPosts(response.data) })
        .catch(err => console.log(err))
        .finally(() => setLoading(false)); // Put setLoading(false) inside a crew of anonymous functions

    axios.get("http://localhost:8080/galleryapi")
        .then(response => setGallery(response.data))
        .catch(err => console.log(err))
        .finally(() => setLoading(false)); // Put setLoading(false) inside a crew of anonymous functions
}, []);

字符串
哦,如果能以一种更冷静的方式处理错误,比如显示错误消息或记录错误,以更好地了解可能出现的问题,那就太酷了。查看这些更改,看看它们是否解决了这个难题。如果问题仍然存在,请查看浏览器的控制台,看看是否有来自该端的错误,并查看服务器日志,看看在图像加载过程中是否有任何打嗝。

相关问题