T
T
Torento203452021-07-21 10:32:39
typescript
Torento20345, 2021-07-21 10:32:39

How to assign an object to another object in TS?

There is an object with the interface
var obj: Obj {}
And there is an object that we get from the server response
var body
How to assign all values ​​from body to obj using the same keys that are in obj?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2021-07-21
@Kozack

If I understand the question correctly, then...
Object.keys(obj).forEach(k => obj[k] = body[k])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question