【发布时间】:2021-07-14 15:36:32
【问题描述】:
我有 404 个异常,我想处理它我尝试了一些方法,但由于仍然有错误,所以无法正常工作
请查看图片
我的目标是:我有一个登录名,并且有一类用户负责人和他的助手,在后端,我有两个集合(我使用 MongoDB Nodejs ionic expressjs)第一个集合是负责人和他的另一个是他的助理,所以在登录时,如果员工编号等于负责人,他将以负责人身份登录并获得管理员访问权限,否则他将成为助理
这是我的代码,我希望你能在我的情况下帮助我,我仍然有我想要解决的 get 错误:
this.Loginser.getdata(this.Form.value.DECAFFE).subscribe(res => {
this.employee = res as Drafbies
this.Loginser.getResponsable(this.employee.DECAFFE).subscribe(re => {
console.log("here the responsible" + re)
}, err => {
if (err.status == 404) {
console.log("is not responsible")
}
})
console.log(res);
})
这里使用的后端方法:
router.get("/responsible", async (req, res) => {
const inv_exerc = await INV_EXERC.findOne({ RESPONSABLE: req.params.responsible })
res.send(inv_exerc)
})
这里是服务:
private readonly url = "http://localhost:3000/auth";
private readonly url2 = "http://localhost:3000/drafbie";
private readonly url3 = "http://localhost:3000/inv_exerc";
private readonly url4 = "http://localhost:3000/inv_agent";
constructor(private http: HttpClient) { }
login(data):Observable<any> {
return this.http.post(this.url, data);
}
getdata(data):Observable<any> {
return this.http.get(this.url2 + `/${data}`);
}
getResponsable(responsible): Observable<any>{
return this.http.get(this.url3+`/${responsible}`)
}
getAgent(agent): Observable<any>{
return this.http.get(this.url4+`/${agent}`)
}
【问题讨论】:
标签: node.js angular express ionic-framework