forked from UzTech/Vue3-typescript-demo
youhua
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import auth from './interfaces/auth'
|
||||
import user from './interfaces/user'
|
||||
import block from './interfaces/block'
|
||||
import esdb from './interfaces/esdb'
|
||||
import user from './interfaces/user'
|
||||
|
||||
export {
|
||||
auth,
|
||||
user,
|
||||
block
|
||||
block,
|
||||
esdb,
|
||||
user
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import Chain33Rpc from '@33cn/chain33-rpc-api'
|
||||
|
||||
export default new Chain33Rpc(process.env.VUE_APP_BLOCK_URL, null)
|
||||
export default new Chain33Rpc(process.env.VUE_APP_BLOCK_URL as string, null)
|
||||
|
||||
46
src/api/interfaces/esdb.ts
Normal file
46
src/api/interfaces/esdb.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { AuthResponse } from '@/types/auth'
|
||||
import axios, { AxiosRequestConfig } from 'axios'
|
||||
|
||||
const request = axios.create({
|
||||
baseURL: process.env.VUE_APP_API_URL as string + process.env.VUE_APP_ESDB_URL as string,
|
||||
timeout: 5000
|
||||
})
|
||||
const axiosConf = (config: AxiosRequestConfig) => {
|
||||
config.headers.Accept = 'application/json'
|
||||
return config
|
||||
}
|
||||
request.interceptors.response.use(async (response) => {
|
||||
if (response.data?.error !== null) {
|
||||
return Promise.reject(response.data.error)
|
||||
}
|
||||
return Promise.resolve(response.data?.result)
|
||||
}, () => {
|
||||
return Promise.reject('网络请求超时')
|
||||
})
|
||||
|
||||
request.interceptors.request.use(axiosConf, err => {
|
||||
return Promise.reject(err)
|
||||
})
|
||||
|
||||
const txList = (size?: number): Promise<AuthResponse> => {
|
||||
const body = {
|
||||
id: 1,
|
||||
method: 'Tx.TxList',
|
||||
params: [{
|
||||
'sort': [{
|
||||
'key': 'height',
|
||||
'ascending': false
|
||||
}],
|
||||
'page': {
|
||||
'number': 1,
|
||||
'size': size
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
||||
return request.post('', body)
|
||||
}
|
||||
|
||||
export default {
|
||||
txList
|
||||
}
|
||||
Reference in New Issue
Block a user