Skip to content

Instantly share code, notes, and snippets.

@gmbarroso
Created November 18, 2021 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmbarroso/2bcee00eece97f90703aaaf22cde81f2 to your computer and use it in GitHub Desktop.
Save gmbarroso/2bcee00eece97f90703aaaf22cde81f2 to your computer and use it in GitHub Desktop.
const orderJSON = require('./order.json');
let simulation = {}
let arrayOfItems = []
const items = Object.values(orderJSON.content.items).map(value => {
let obj = {
"id": value.id,
"quantity": value.quantity,
"seller": "1"
}
return obj
})
const getPostalCode = Object.values(orderJSON.content.shippingData)[0].postalCode
const getCountry = Object.values(orderJSON.content.shippingData)[0].country
simulation = {
"items": items,
"postalCode": getPostalCode,
"country": getCountry
}
console.log(JSON.stringify(simulation))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment