| 1234567891011121314151617181920212223242526272829303132 |
- import axios from 'axios'
- import qs from 'qs'
- const http = axios.create({
- baseURL: 'http://localhost:8080'
- })
- const { data: token } = await http.post(
- 'http://localhost:8080/auth/login',
- qs.stringify({
- username: '15077886171',
- password: '123456'
- })
- )
- http.defaults.headers.common['Authorization'] = `Bearer ${token}`
- const {
- data: { content: list }
- } = await http.post('/product/list', {
- page: 0,
- size: 20,
- sort: 'delayTo,asc;sales,desc;',
- query: { batchId: '11548', status: 'IN_STOCK' }
- })
- for (let i = 0; i < 3; i++) {
- http.post('/order/createOrder', `productId=${list[0].id}`)
- .then(res => {
- console.log('success')
- })
- .catch(e => {
- console.log(e.response.data.error)
- })
- }
|