Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

153
Vistas
How to map request parameter fields in angular-httpclient?

I have an angular project that has a user registration form that creates the following Registration object which is then passed into a register service. However, the service request parameters are underscore_cased. How can I remap firstName and lastName to first_name and last_name before I send the http request?

export class Registration {
  email: string;
  firstName: string;
  lastName: string;
}

register(registration: Registration) {
    console.log('Registration submitted', registration);
    return this.http.post(`${environment.authUrl}/auth/register`, registration).pipe(
       catchError(err => {
            console.log('Handling error locally and rethrowing it...', err);
            return throwError(err);
       })
    );
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can create a new object with desired key name and initialize that newly created object with registeration object's value.

register(registration: Registration) {
  const registerUserObject = {
    'first_name' : registration.firstName,
    'last_name' : registration.lastName,
    'email' : registration.email
  } ;
   
  return this.http.post(`${environment.authUrl}/auth/register`, registerUserObject).pipe(...);
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda