English | 简体中文
Remote data fetching solution for Promise-based Ajax request chain
import {xs} from 'xswr'
import service from './service'
const fetchAssetInfo() {
xs("/api/account", fetcher, {
staleWhileRevalidateMS: 1000,
poolingInterval: 1000,
}).then(account => {
const {assetsId} = account.data
return xs(["/api/assets", {id: assetsId}], (url, params) => {
return fetch(url, params)
})
}).then(assets => {
// handle assets
}).catch(err => {
// handle error
})
}
const promise = xs(key, fetcher, config)