0.2.6 • Published 1 year ago

@alphabetabc/utils v0.2.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@alphabetabc/utils

runPromise

const promiseFn = async () => Promise.resolve();
const [error, result] = await runPromise(promiseFn());
if (err) {
    return;
}

BrowserCjsLoader

new BrowserCjsLoader().init(window);
require('echarts');

createRequestApi

// 创建Api
const api = createRequestApi({
    baseURL: 'http://geo.datav.aliyun.com',
});

console.log('log---api', api);

// 直接使用实例方法
api.get('/areas_v3/bound/100000_full.json', {})
    .then((res) => {
        console.log('log---res', res.data);
    })
    .catch((e) => {
        console.log('log---', e);
    });

// 定义api
const currentApi = api.create('http://geo.datav.aliyun.com/areas_v3/bound/100000_full.json', {
    type: 'get',
    data: { value: 1 },
});

// 使用api发送请求
const current = currentApi.send({ timestamp: Date.now() });

// 获取数据
current
    .then((res) => {
        console.log('log---res--2', res.data);
    })
    .catch((e) => {
        console.log('log---2', e);
    });

// 取消请求
current.abort();
0.2.1

1 year ago

0.2.0

1 year ago

0.2.6

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

2 years ago

0.1.0

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago