backend: I have REST API request Body contains one enum parameter ExperienceType
frontend :
export enum ExperienceType {
ENTRY,
INTERMEDIATE,
EXPERIENCED,
EXPERT,
}
export const ExperienceTypeMapping = [
{value: ExperienceType.ENTRY, type: 'ENTRY'},
{value: ExperienceType.EXPERIENCED, type: 'EXPERIENCED'},
{value: ExperienceType.EXPERT, type: 'EXPERT'},
{value: ExperienceType.INTERMEDIATE, type: 'INTERMEDIATE'}
];
when i m make post request its looks like object ( {value: 2 , type: "Entry" } ) and not just String "ENTRY" :
get values from form :
vacancyForm = this.formBuilder.group({
..........................
experienceType: ['', [Validators.required]],
..........................
});
this.vacanciesService.createVacancy(this.vacancyForm.value).subscribe() ....
so i want to change request Body from object to string {value: 2 , type: "Entry" } to -> "Entry"
Im try following but not works :
temp=this.vacancyForm.get('experienceType').get('type'))
this.vacancyForm.controls.experienceType.setValue(temp);
You can try something like
this.vacanciesService.createVacancy({
...this.vacancyForm.value,
experienceType: this.vacancyForm.get('experienceType').get('type')
}).subscribe()