Skip to content

Instantly share code, notes, and snippets.

@jacky810124
Created March 19, 2018 12:47
Show Gist options
  • Save jacky810124/0b3b9f9487bb200c73a240a6e5280073 to your computer and use it in GitHub Desktop.
Save jacky810124/0b3b9f9487bb200c73a240a6e5280073 to your computer and use it in GitHub Desktop.
array = (new Array(5000)).fill(1)
task = array.map(item => {
return fetch('http://localhost:5000/diandian-landing-payment/us-central1/api/test')
})
duplicated = []
Promise
.all(task)
.then(result => result.map(item => item.json()))
.then(result => result.map(item => {
return item.orderId
}))
.then(result => {
duplicated = result.filter((item, index) => {
if (result.indexOf(item) !== result.lastIndexOf(item) && result.indexOf(item) === index) {
return true
}
return false
})
console.log(duplicated)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment