0

How to move object into the outer object's contained nested object?

{ criteria: 
   { provider: 2,
     providerName: 'CLX_gw0',
     mcc: null,
     mnc: null,
     dial_code: null,
     active: 1 },
  page: 1,
  pageSize: 50 }

I want like this:

{
    provider: 2,
    providerName: 'CLX_gw0',
    mcc: null,
    mnc: null,
    dial_code: null,
    active: 1,
    page: 1,
    pageSize: 50 
}
3
  • 1
    Have you tried anything or do you simply want that someone else works for you?
    – Tomalak
    Commented Mar 31, 2016 at 13:56
  • You'll have to create the object manually. Commented Mar 31, 2016 at 13:56
  • i tried to use flatten/flattenDeep but this for array only? i guessed to be some method
    – AxOn
    Commented Mar 31, 2016 at 13:57

1 Answer 1

1

Try this. You don't even need lodash:

const newObj = Object.assign({}, obj, obj.criteria);
delete newObj.criteria;

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.