发布于2024-11-30 03:33 阅读(209) 评论(0) 点赞(3) 收藏(0)
我有两个具有相同属性的表(大学表和高中表)。我想要做的是将数据从大学表发送到高中表。例如,我在大学表中有 Datmor 学院,如果我按下带有名为 sendtoHighSchool() 的函数的按钮,Datmor 学院应该会发布到高中表。
当我点击“发送到高中”按钮时,我看到数据已经正确获取,但我仍然收到此错误
" POST http://localhost:3000/api/college_api/v1/colleges 500 (Internal Server Error)
error_handler.js:47 EXCEPTION: Response with status: 500 Internal Server Error for URL: http://localhost:3000/api/college_api/v1/colleges
ErrorHandler.handleError @ error_handler.js:47
next @ application_ref.js:272
schedulerFn @ async.js:82
SafeSubscriber.__tryOrUnsub @ Subscriber.js:223
SafeSubscriber.next @ Subscriber.js:172
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ async.js:74
NgZone.triggerError @ ng_zone.js:278
onHandleError @ ng_zone.js:257
ZoneDelegate.handleError @ zone.js:236
Zone.runTask @ zone.js:157
ZoneTask.invoke @ zone.js:335
Subscriber.js:227 Uncaught Response {_body: "<!DOCTYPE html>↵<html>↵ <head>↵ <meta ch…l>↵</div>↵↵ </div>↵ </body>↵</html>", status: 500, ok: false, statusText: "Internal Server Error", headers: Headers…}
SafeSubscriber.__tryOrUnsub @ Subscriber.js:227
SafeSubscriber.next @ Subscriber.js:172
Subscriber._next @ Subscriber.js:125
Subscriber.next @ Subscriber.js:89
Subject.next @ Subject.js:55
EventEmitter.emit @ async.js:74
NgZone.triggerError @ ng_zone.js:278
onHandleError @ ng_zone.js:257
ZoneDelegate.handleError @ zone.js:236
Zone.runTask @ zone.js:157
ZoneTask.invoke @ zone.js:335"
//桌子
<td><a class="btn btn-success" (click)="addToHighSchool()"><em class="fa fa-plus"></em></a>Send to High school</td>
//学院部分
addToHighSchool(college) {
this.httpService.add(college)
.subscribe(data =>{
console.log(data)
});
console.log(college)
}
//服务
add(user:any) {
const body = JSON.stringify(user);
const headers = new Headers();
headers.append('Content-Type', 'application/json');
return this.http.post('http://localhost:3000/api/college_api/v1/colleges', body, {headers: headers})
.map((data:Response) => data.json());
}
app/Http/Middleware/VerifyCsrfToken.php 找到这个并写入保护
$except = [ 'api/*' ];
然后找到路线并修改
<?php Route::group(['prefix' => 'api', 'middleware' => ['cors']], function(){ Route::resource('courses', 'CourseController', ['except' => [ 'create', 'edit' ]]); });
作者:黑洞官方问答小能手
链接:http://www.phpheidong.com/blog/article/556012/b269967572d30d13ba77/
来源:php黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 php黑洞网 All Rights Reserved 版权所有,并保留所有权利。 京ICP备18063182号-4
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!