Last active
November 18, 2018 10:18
-
-
Save alfari16/ab798000e87ef9141a1ef57c06e6ed9c to your computer and use it in GitHub Desktop.
Sebuah tes untuk melakukan pemesanan secara concurrent
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
| const axios = require('axios') | |
| const doTest = async (idx) => { | |
| const { data } = await axios.post( | |
| 'http://localhost:3000/orders/create', | |
| { | |
| items: [ | |
| { | |
| id: 6, //id produk | |
| item: 2, //jumlah produk yg dibeli | |
| total: 35000 //total harga | |
| }, | |
| { | |
| id: 5, | |
| item: 2, | |
| total: 26000 | |
| } | |
| ] | |
| }, | |
| { | |
| headers: { | |
| Authorization: | |
| 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZW1haWwiOiJ1c2VyMUBlbWFpbC5jb20iLCJpYXQiOjE1NDE5MTU3MjEsImV4cCI6MTU3MzAxOTcyMX0.clFglco3ZWRPb5xw1eJdTRURp2cdGi89lrJqWArpbFY' | |
| } | |
| } | |
| ) | |
| console.log(`Transaction id #${idx}`, data) | |
| } | |
| Promise.all([doTest(1), doTest(2), doTest(3), doTest(4)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment