首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >获取http://localhost:3000/posts/timeline/(objId) 500 (内部服务器错误)-默认(承诺)AxiosError{‘状态代码500的请求失败’

获取http://localhost:3000/posts/timeline/(objId) 500 (内部服务器错误)-默认(承诺)AxiosError{‘状态代码500的请求失败’
EN

Stack Overflow用户
提问于 2022-05-28 05:08:55
回答 1查看 1.7K关注 0票数 0
代码语言:javascript
运行
复制
export default function Feed() {
  const [posts, setPosts] = useState([]);
  const PF = process.env.REACT_APP_PUBLIC_FOLDER;

  useEffect(() => {
    const fetchPosts = async () => {
      const res = await axios.get("posts/timeline/628f04a81b8f4431e49b6679");
      console.log(res);
      setPosts(res.data);
    };
    fetchPosts();
  }, []);

在运行这段代码时,我得到以下内容:

代码语言:javascript
运行
复制
GET http://localhost:3000/posts/timeline/628f04a81b8f4431e49b6679 500 (Internal Server Error)
dispatchXhrRequest @ xhr.js:220
xhrAdapter @ xhr.js:16
dispatchRequest @ dispatchRequest.js:58
request @ Axios.js:109
Axios.<computed> @ Axios.js:131
wrap @ bind.js:9
fetchPosts @ Feed.jsx:13
(anonymous) @ Feed.jsx:17
commitHookEffectListMount @ react-dom.development.js:23049
commitPassiveMountOnFiber @ react-dom.development.js:24816
commitPassiveMountEffects_complete @ react-dom.development.js:24781
commitPassiveMountEffects_begin @ react-dom.development.js:24768
commitPassiveMountEffects @ react-dom.development.js:24756
flushPassiveEffectsImpl @ react-dom.development.js:26990
flushPassiveEffects @ react-dom.development.js:26935
(anonymous) @ react-dom.development.js:26725
workLoop @ scheduler.development.js:266
flushWork @ scheduler.development.js:239
performWorkUntilDeadline @ scheduler.development.js:533

这是系统无法获取数据的第一个错误。我被困在这里一段时间了。我是全新的反应,所以如果有人能解决这一问题,并解释,如果你是一个婴儿解释将是伟大的。这样我就能更容易地理解它了。谢谢

代码语言:javascript
运行
复制
Feed.jsx:16 Uncaught (in promise) 
AxiosError {message: 'Request failed with status code 500', name: 'AxiosError', code: 'ERR_BAD_RESPONSE', config: {…}, request: XMLHttpRequest, …}
code: "ERR_BAD_RESPONSE"
config: {transitional: {…}, transformRequest: Array(1), transformResponse: Array(1), timeout: 0, adapter: ƒ, …}
message: "Request failed with status code 500"
name: "AxiosError"
request: XMLHttpRequest {onreadystatechange: null, readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, …}
response: {data: {…}, status: 500, statusText: 'Internal Server Error', headers: {…}, config: {…}, …}
[[Prototype]]: Error
fetchPosts  @   Feed.jsx:16
await in fetchPosts (async)     
(anonymous) @   Feed.jsx:17
commitHookEffectListMount   @   react-dom.development.js:23049
commitPassiveMountOnFiber   @   react-dom.development.js:24816
commitPassiveMountEffects_complete  @   react-dom.development.js:24781
commitPassiveMountEffects_begin @   react-dom.development.js:24768
commitPassiveMountEffects   @   react-dom.development.js:24756
flushPassiveEffectsImpl @   react-dom.development.js:26990
flushPassiveEffects @   react-dom.development.js:26935
(anonymous) @   react-dom.development.js:26725
workLoop    @   scheduler.development.js:266
flushWork   @   scheduler.development.js:239
performWorkUntilDeadline    @   scheduler.development.js:533

这就是我得到的公理错误

EN

回答 1

Stack Overflow用户

发布于 2022-09-15 05:56:32

打开您的开发工具,然后转到网络并删除用户日志,例如,获取http://localhost:3000/posts/timeline/628f04a81b8f4431e49b6679,删除用户,它就能工作了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72413021

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档