简体   繁体   English

获取错误 - 使用 POST 时不允许接收 405 GET 方法

[英]Fetch error - Receiving 405 GET Method Not Allowed While Using POST

I am trying to deploy an app where I have to register to get a JSON with my data ( username , email , password ) from the backend.我正在尝试部署一个应用程序,我必须在其中注册才能从后端获取带有我的数据( usernameemailpassword )的 JSON。 I linked the frontend to backend with a fetch (the code is attached).我通过 fetch 将前端链接到后端(代码已附加)。 My fetch request has a POST method, but I get this error, whilst I am not using any GET method, why so?我的 fetch 请求有一个 POST 方法,但是我得到了这个错误,而我没有使用任何 GET 方法,为什么会这样?

 fetch('link/signup' /*will be changed with correct URL tomorrow*/,{ method: 'POST', /* method: 'POST', body: formData, */ headers: { "Content-Type": "application/json", }, body: JSON.stringify({ username: username.value, email: email.value, password: password.value, }), }).then((response) => { return response.json(); }).catch((error) => { console.log('Request failed', error); });

GET https://link/signup/ 405 (Method Not Allowed) (anonymous) @ registration.9bbdb929a0502d2a723f.js:68 GET https://link/signup/ 405(方法不允许)(匿名)@registration.9bbdb929a0502d2a723f.js:68

It's weird, but some APIs are not case-sensitive.这很奇怪,但有些 API 不区分大小写。 Try to write 'post' instead 'POST' and see尝试写 'post' 而不是 'POST' 看看

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM