data.map is not a function

后端 未结 9 1133
轮回少年
轮回少年 2020-12-02 05:50

I\'m bashing my head against an error I can\'t work out how to fix. I have the following;

JSON

{\"products\":
[
    {
        \"product_id\" : \"123         


        
9条回答
  •  萌比男神i
    2020-12-02 06:31

    If you want to map an object you can use Lodash. Just make sure it's installed via NPM or Yarn and import it.

    With Lodash:

    Lodash provides a function _.mapValues to map the values and preserve the keys.

    _.mapValues({ one: 1, two: 2, three: 3 }, function (v) { return v * 3; });
    
    // => { one: 3, two: 6, three: 9 }
    

提交回复
热议问题