HTTP POST request with fetch() method not allowed
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- javascript
调研方向
从 fetch('/api', options) 调用开始,跟踪处理 /api 请求的 handler 或 route。在本地复现 405,然后验证该 endpoint 接受所示的 POST 请求,不再以 405 响应拒绝该请求。
由索引模型根据 Issue 内容生成。
描述
Post with fetch() does not work on my localhost on both Apple and Windows.
This line of code const response = await fetch("/api", options); throws a 405 error saying that the method is not allowed. So, no data is sent to the server. Any ideas?
Here is the larger snippet let lat, lon;
const button = document.getElementById("submit");
button.addEventListener("click", async (event) => {
const data = { lat, lon };
const options = {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
};
const response = await fetch("/api", options);
const json = await response.json();
console.log(json);
});
- 主要语言
- HTML
- 星标
- 759
- 派生
- 591
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
CodingTrain/Intro-to-Data-APIs-JS 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 45/100
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 5/5 一周以上 新手友好度 5/100
-
难度 5/5 一周以上 新手友好度 1/100
-
难度 5/5 一周以上 新手友好度 10/100
查看 CodingTrain/Intro-to-Data-APIs-JS 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 3 天内回复
-
backend dev experience good first issue
难度 2/5 1-3 小时 新手友好度 78/100
cuttle-cards/cuttle#1401 ·
维护者通常 1 天内回复
-
good first issue
难度 2/5 1-3 小时 新手友好度 83/100
btclib-org/btclib-wallet#267 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
langchain-ai/langmem#194 ·