简体   繁体   English

错误:TypeError:无法在“窗口”上执行“获取”:名称无效。 这里可能是什么问题?

[英]Error: TypeError: Failed to execute 'fetch' on 'Window': Invalid name. What could be the issue here?

I am getting a type error:我收到类型错误:

Error: TypeError: Failed to execute 'fetch' on 'Window': Invalid name at HTMLFormElement.loginDataHandler (index.js:77:9)错误:TypeError:无法在“窗口”上执行“获取”:HTMLFormElement.loginDataHandler 处的名称无效(index.js:77:9)

I have searched google for hours now and tried all the suggested solutions but noe seem to be working on my end.我已经在谷歌上搜索了几个小时并尝试了所有建议的解决方案,但似乎没有人能解决我的问题。

I am stuck, can't make any progress.我被卡住了,无法取得任何进展。

 function loginDataHandler(e) { e.preventDefault(); loginObject = { email: emailInput.value, passwordInput: passwordInput.value }; console.log(loginObject); const newLocal = "https://mawingu.cbaloop.com/cba/api/v1/access/login"; fetch(newLocal, { method: 'POST', body: JSON.stringify(loginObject), credentials: 'include', headers: { 'Content-Type': 'application/json', 'Access-Contr"ol-Allow-Origin': 'http://localhost:5500', " Access-Control-Allow-Methods ": "POST", ' Authorization ': ` None `, "Access-Control-Allow-Headers": "X-Requested-With", 'referrerPolicy': 'no-referrer' }, }) .then( res => res.json() ) .then( data => console.log(data) ) .catch((error) => { console.log('Error:', error); }); }

what could be the issue?可能是什么问题?

you need to remove the following:您需要删除以下内容:

'Access-Contr"ol-Allow-Origin': 'http://localhost:5500',
" Access-Control-Allow-Methods ": "POST",
' Authorization ': ` None  `,

it will submit the request.它将提交请求。

暂无
暂无

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

相关问题 类型错误:无法在“窗口”上执行“获取”:Yelp API 的名称无效 - TypeError: Failed to execute 'fetch' on 'Window': Invalid name WITH Yelp API 未捕获(承诺)类型错误:无法在“窗口”上执行“获取”:名称无效 - Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'Window': Invalid name TypeError:无法在“窗口”上执行“获取”:无效值 - TypeError: Failed to execute 'fetch' on 'Window': Invalid value TypeError:无法在“窗口”上执行“获取” - TypeError: Failed to execute 'fetch' on 'Window' 获取类型错误:无法在“窗口”上执行“获取”:非法调用 - Fetch TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 类型错误:无法在“窗口”上执行“获取”:需要 1 个参数,但只有 0 个存在 - TypeError: Failed to execute 'fetch' on 'Window': 1 argument required, but only 0 present Reactjs - TypeError:无法在“Window”上执行“fetch”:无法解析来自 ***.**.*.***:2000 的 URL - Reactjs - TypeError: Failed to execute 'fetch' on 'Window': Failed to parse URL from ***.**.*.***:2000 类型错误:向服务器发送 JWT 时无法在“窗口”上执行“获取” - Type Error: Failed to execute 'fetch' on 'Window' when Sending a JWT to server TypeError:无法在“窗口”上执行“获取”:使用 GET/HEAD 方法的请求不能有正文 - TypeError: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body 获取错误:TypeError:无法获取 - Getting Error: TypeError: Failed to fetch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM