Created
March 18, 2018 05:37
-
-
Save sultanshakir/0df9f38902edd6e7bdaf80003e5dbdf1 to your computer and use it in GitHub Desktop.
Turns Array keys into JSON keys
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = (dataToConvert) => { | |
| let data = {} | |
| dataToConvert.forEach((val, index) => { | |
| data[Object.keys(dataToConvert[index])] = Object.values(dataToConvert[index])[0] | |
| }) | |
| return data; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment