Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!