1

I am getting an object in angular that looks like this:

quiz.js:129 m {$promise: Promise, $resolved: false}
   439:"https://mysite.no/sites/default/files/styles/quiz_large/public/fields/question-image/istock_000059790188_large.jpg?itok=62PzCown"
   679: ""
   1379:"https://mysite.no/sites/default/files/styles/quiz_large/public/fields/question-image/istock_000000301688_medium.jpg?itok=poGpHb5c"
   1529:"https://mysite.no/sites/default/files/styles/quiz_large/public/fields/question-image/istock_000011483027_large.jpg?itok=LJ3f0c-X"
   2022:"https://www.mysite.no/sites/default/files/styles/quiz_large/public/fields/question-image/208458_thumbnail.jpg?itok=6AG_2XS3"
   $promise: Promise
   $resolved: true__proto__: Object

I would need to make an array out of that data, but not sure how to make this.

Ludwig
  • 1,401
  • 13
  • 62
  • 125

2 Answers2

1

What have you tried? This is one way of doing it, though the error your getting doesn't seem to point that this is the issue.

var arr = Object.keys(obj)
    .map(function(key) { return obj[key] });
Martin
  • 15,820
  • 4
  • 47
  • 56
0

You can lodash _.values(obj) this will creates an array of values of this object.

Here is the documentation and here is the fiddle for the same.

I hope this helps, Thanks.

var obj = { 
     439:"https://mysite.no/sites/default/files/styles/quiz_large/public/fields/question-image/istock_000059790188_large.jpg?itok=62PzCown",
     679: "",
     1379:"https://mysite.no/sites/default/files/styles/quiz_large/public/fields/question-image/istock_000000301688_medium.jpg?itok=poGpHb5c",
     1529:"https://mysite.no/sites/default/files/styles/quiz_large/public/fields/question-image/istock_000011483027_large.jpg?itok=LJ3f0c-X",
     2022:"https://www.mysite.no/sites/default/files/styles/quiz_large/public/fields/question-image/208458_thumbnail.jpg?itok=6AG_2XS3"
    }
  console.log(_.values(obj));
Vipul Panth
  • 5,221
  • 4
  • 16
  • 27