0

can someone tell me why this doesnt work?

    OnSubmit = () => {
      this.SetAttributesForDTO(this.state.attributeList, this.test = () => {
          //Test Function gets called after this.SetAttributesForDTO function
      })}

i want a function which calls first "SetAttributesForDTO" and after that function is done, i want to call anotherone ..

Terraya
  • 121
  • 1
  • 8
  • 2
    I suggest you use promises, which would fulfill a solution to your problem. – Mitchell Lewis Mar 21 '20 at 12:58
  • Welcome to Stack Overflow! Please take the [tour] (you get a badge!), have a look around, and read through the [help], in particular [*How do I ask a good question?*](/help/how-to-ask) We can't help you with just the information above, we need more. Does `SetAttributesForDTO` accept a callback? Does it do its work asynchronously? Does it return a promise? Why are you assigning the function to a `test` property? Etc. :-) – T.J. Crowder Mar 21 '20 at 13:00
  • Thanks @T.J.Crowder , my function doesnt accept a callback but i could implement it, never worked with callbacks but i will give it a try, it work asynchronously yes, it doesnt return any promise, and im assigning it to a test property becouse i just want to see it work – Terraya Mar 21 '20 at 13:01
  • If `SetAttributesForDTO` accepts a callback as its second argument, what you have should work (though you don't need to assign the function to `this.test`). So you'll need to look into why `SetAttributesForDTO` isn't calling the callback, which we can't help you with without knowing more about that function. – T.J. Crowder Mar 21 '20 at 13:09
  • Test is just a simple small test function which logs something to the console test = () => { console.log("test"); } – Terraya Mar 21 '20 at 13:14
  • check this question: https://stackoverflow.com/questions/5000415/call-a-function-after-previous-function-is-complete – Luis Montoya Mar 21 '20 at 13:17
  • Thanks @LuisFernandoMontoya exactly what i need – Terraya Mar 21 '20 at 13:35

0 Answers0