Created
November 18, 2021 15:20
-
-
Save gmbarroso/c031023f66d1373ca7cba22baf94a343 to your computer and use it in GitHub Desktop.
This file contains 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
const url = "https://raiadrogasil.myvtex.com/checkout/cart/add/?sku=70288&qty=1&seller=1&sc=1?sku=12345&qty=1&seller=1&sc=1?sku=10253&qty=1&seller=1&sc=1" | |
let items = [] | |
const parameters = url.match(/\A?sku=[^&]+&\A?qty=[^&]+&*\A?seller=[^&]+&*/g) | |
console.log(parameters) | |
simulation = parameters.map(value => { | |
let obj = { | |
"id": value.match(/([\d]+)/g)[0], | |
"quantity": value.match(/([\d]+)/g)[1], | |
"seller": "1" | |
} | |
return obj | |
}) | |
console.log(JSON.stringify(simulation)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment