【发布时间】:2020-07-26 21:24:01
【问题描述】:
嗨,我有一个函数,我想发送两个 http 请求,第二个请求只是在第一个请求完成后,我在管道内使用 switchMap,条件基于一个角度形式,我的编辑器显示下一个错误:
Argument of type '(data: Object) => void' is not assignable to parameter of type '(value: Object, index: number) => ObservableInput<any>'.
Type 'void' is not assignable to type 'ObservableInput<any>'.
这是我的功能:
store() {
this.empleadosEmpleadoService.store({
fecha_contratacion: this.empleadoForm.value.fecha_contratacion,
fecha_nacimiento: this.empleadoForm.value.fecha_nacimiento,
curp: this.empleadoForm.value.curp,
rfc: this.empleadoForm.value.rfc,
telefono: this.empleadoForm.value.telefono,
user: {
email: this.empleadoForm.value.email,
username: this.empleadoForm.value.username,
password: this.empleadoForm.value.password,
first_name: this.empleadoForm.value.first_name,
last_name: this.empleadoForm.value.last_name
}
}).pipe(
switchMap(data =>{
if(this.empleadoForm.value.foto){
this.empleadosEmpleadoService.subirFoto(
data['user_id'],
this.empleadoForm.value.foto
)
}
})
).subscribe(async empleado => {
if(empleado) {
this.empleadoForm.reset();
this.empleadoAgregado.emit(empleado);
this.dismissModal();
}
});
}
【问题讨论】:
标签: javascript angular typescript ionic-framework observable