0

I am grouping payloads with merge map, and to be able to separate the results, i want to have a series of Json (objects) as Arrays. Like this: {Array1:[]}, Array2:[]} I use the toArray() operator to get the payload as an Array, but i dont now (maybee map operator) how to put this array in an Object (Json).

const image$ = ref.getDownloadURL().pipe(toArray());

The result is: [ {...}, {...}, {...} ] And what i want is: { objectName:[ {...}, {...}, {...} ] }

Thanks for your help.

5
  • 3
    just use map() I guess. Like map(array => ({objectName: array })) Commented Dec 9, 2019 at 12:41
  • how do you get the objectName? Would you have multiple different keys like this? Commented Dec 9, 2019 at 12:41
  • No i just want one object name like this: { objectName:[ {...}, {...}, {...} ] } Commented Dec 9, 2019 at 12:45
  • In that case, Martin's answer is the way to go Commented Dec 9, 2019 at 12:47
  • map(array => ({objectName: array })) This solution is working perfectly, so the code is: const image$ = ref.getDownloadURL().pipe(toArray(), map(array => ({objectName: array }))); Commented Dec 9, 2019 at 12:48

1 Answer 1

1

The answer is :

const image$ = ref.getDownloadURL().pipe(toArray(), map(array => ({objectName: array })));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.