我想实现身份验证.实际上,我的项目是在Angular 2 Beta中构建的,但我正在使用
this身份验证示例进行测试.我有自己的API,只是将其url添加到此示例项目中.它没有用)它显示了这个错误:
原文链接:https://www.f2er.com/angularjs/143218.htmlFailed to load resource: the server responded with a status of 405 (Method Not Allowed) Fetch API cannot load http://blah-blah-blah. Response for preflight has invalid HTTP status code 405
login(event,phone,password) { event.preventDefault(); window.fetch('http://blah-blah-blah',{ method: 'POST',headers: { 'Accept': 'application/json','Content-Type': 'application/json' },body: JSON.stringify({ phone,password }) }) .then(status) .then(json) .then((response:any) => { localStorage.setItem('access_token',response.id_token); this.router.parent.navigateByUrl('/home'); }) .catch((error) => { alert(error.message); console.log(error.message); }); }