Add object to request body from angular to nodejs

I have a yaml file of this format:

Layouts:
        -
          Name: Default Layout
          LayoutId : 1
          ConfiguredSegments:
            LiveA :
                Height : 100
                Id : LiveA
            Ref1A :
                Height : 100
                Id : Ref1A

I have a function like this on my nodejs server side which is used to replace a field ‘ConfiguredSegments ‘ in my yaml file:

//function to update specific layout based on LayoutId
export const updateSpecificLayout = (req, res)=>{
    const { id } = req.params;
    const { ConfiguredSegments } = req.body;

    const getLayoutList = JSON.parse(JSON.stringify(layoutData)); 

    const layoutToBeUpdated = getLayoutList.Layouts.find((layout) => layout.LayoutId == id );

    findAndReplace(getLayoutList.Layouts,layoutToBeUpdated.ConfiguredSegments,ConfiguredSegments)

      let yaml = YAML.dump(getLayoutList);
     
       fs.writeFileSync("layouts.yaml", yaml, function (err,file){
          if(err) throw err;        
          console.log(`Layout with the id:${id} has been updated`);
  })      

    res.send(`Layout with the id:${id} has been updated`);
    console.log(`Layout with the id:${id} has been updated`);
}

From angular side i am trying to update configured segments :

conseg:any;
confseglist:any;

conseg = {
"ConfiguredSegments": {
"SomeSegment": {
"Height": 9999,
"Id": "Hello"
}
}

//appSettingsService is my service instance
 this.appSettingsService.updateSpecificLayout ("1").subscribe(data => {   

  this.confseglist= Object.values(data);
  //Here i want to add body as 'conseg ' to my patch request
  
 })

My http service class:

I understand that i have to pass my ‘conseg ‘ in the body.

//Update specific layout based on layout ID
updateSpecificLayout(id: string) {
    const urlLayout = `${this._url}/${id}`;
    return this.http.patch(urlLayout, conseg ).pipe(catchError(this.errorHandler))
}

But i am not getting how to add body to my patch request

Answer

This line:

this.appSettingsService.updateSpecificLayout (“1”).subscribe(data => {

update to:

this.appSettingsService.updateSpecificLayout (“1”, conseg).subscribe(data => {

and update your service to:

updateSpecificLayout(id: string, conseg: any) {