javascript - Create a new Object on Json after click (http.put) -


i have following json structure:

"disputas": [     {       id: "",       tipo_negociacao: "",       historico:{          fl_usuario: "",          created_at: "",          updated_at: "",          created_by: null,          updated_by: null,          texto: "",       }     } ] 

i updating json using http.put, want create object of historico each time click on button, this:

"disputas": [     {       id: "",       tipo_negociacao: "",       historico:{          fl_usuario: "",          created_at: "",          updated_at: "",          created_by: null,          updated_by: null,          texto: "",       },          historico:{          fl_usuario: "",          created_at: "",          updated_at: "",          created_by: null,          updated_by: null,          texto: "",       }     } ] 

how can this?

this service:

url: string = 'http://localhost:3004/disputa'; constructor(private http: http){} atualizadisputa (body:object): observable<disputapropostacomponent[]>{     let bodystring = json.stringify(body); // stringify payload     let headers      = new headers({ 'content-type': 'application/json' }); // ... set content type json     let options       = new requestoptions({ headers: headers }); // create request option     return this.http.put(`${this.url}/${body['id']}`, body, options) // ...using post request                      .map((res:response) => res.json()) // ...and calling .json() on response return data                      .catch((error:any) => observable.throw(error.json().error || 'ocorreu um erro em nosso servidor, tente novamente mais tarde')); //...errors if } 

thanks in advance. let me know if guys need more code.

you can't have 2 keys named historico on object. you'll need turn array. once can push onto array usual.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -