.
This commit is contained in:
25
Web/public/doc-code/api/usage.js
Normal file
25
Web/public/doc-code/api/usage.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import { api } from 'common/api'
|
||||
|
||||
api.apiName(params)
|
||||
.then(res => {
|
||||
/* ... */
|
||||
})
|
||||
.catch(error => {
|
||||
/* catch */
|
||||
})
|
||||
.finally(() => {
|
||||
/* finally */
|
||||
})
|
||||
|
||||
|
||||
// 或者采用异步
|
||||
async function foo() {
|
||||
try {
|
||||
const res = await api.apiName(params)
|
||||
/* ... */
|
||||
} catch (error) {
|
||||
/* catch */
|
||||
} finally {
|
||||
/* finally */
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user