基本上,我试图通过POST将数据添加到数据库中。 我无法弄清楚我的错误在哪里。在此先感谢您提出任何想法。
My error:
[enter image description here][1]
**type script**
Here all parameter is provided(pha_id,per_id,month,year...)
this.http.post('/api/auslastung/addAuslastung', {
hidden_id_phase: pha_id,
personen_id:per_id,
personen_wunsch_id:0,
Monat: month,
Jahr: year,
Auslastung:newauslastung_value,
Rolle:rolle
},{ responseType: 'text' }).subscribe(data => {
this.getAuslastung();
} ,
err => {console.log(err)});
///////////////
这是我的Api控制器
@Post()
public async addAuslastung(req: Request, res: Response) {
await new AuslastungRepository().addAuslastung(
req.body['hidden_id_phase'] ,req.body['Personen_ID'] ,
req.body['Personen_Wunsch_ID'],
req.body['Monat'], req.body['Jahr'],
req.body['Auslastung'], req.body['Rolle']
)
res.send(200);
}
////////////////////// 仓库
public async addAuslastung(phaseId:number,personenenid:number,
personenwunschid:number,Monat : string , Year: string ,auslastung:Float32Array,rolle: string){
await Database.knex('Ressource')
.insert(({
hidden_id_phase:phaseId,
Personen_ID:personenenid,
Personen_Wunsch_ID:personenwunschid,
Monat:Monat,
Jahr:Year,
Auslastung:auslastung ,
Rolle:rolle
}
//and my GetAuslastung funstion works well.So I assume problem is not that.
public async getAuslastung(state: 'ongoing' | 'completed'): Promise<auslastungListItemViewModel[]> {
const auslastung = await Database.executeFile('GetAuslastung.sql','auslastung',{
showOngoing: state === 'ongoing',
showCompleted: state === 'completed'
});
return auslastung;
}
答案 0 :(得分:1)
所以我意识到没有错。但是我只需要用ng build -w来重建项目。但是我会保留这个职位,以防有人在某个地方使用它。