0
I am currently making a request get in the backend but is returning data that I will not use, I would like to copulate my model only with the data that was created.
My model:
export class Cliente {
public nome: string;
public cnpj_rg: string;
public cpf_inscricao: string;
public email: string;
public telefone: string;
public sexo: string;
public data_nascimento: string;
public oferta_email: boolean;
public informacoes_sms: boolean;
}
My http request:
recuperaUsuario() : void {
this.loadingService.alteraEstadoLoading(true)
this.clienteService.recuperarCliente()
.pipe(take(1))
.subscribe((res ) => {
this.cliente = res.body;
this.loadingService.alteraEstadoLoading(false)
},
(err: HttpErrorResponse) => {
})
}
My service:
recuperarCliente() : Observable<any> {
return this.http.get<Cliente>(AppSettings.API_ENDPOINT + 'clientes/dados-cadastrais', {observe: 'response'})
}
My problem is that my backend is returning more keys than necessary and my model ends up being copied by them causing me some problems when sending this data to the backend.
Is there any way I can copulate only the keys in my model?
vc have to use the map operator and map the object manually.
– Eduardo Vargas
You can provide me with an example of how to do this?
– veroneseComS