@vuni/request
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

Fetch 的 简单的封装

    const request = createFetch({
		// 不填就使用 baseURLs
		baseURL: 'https://lop-api.vertu.com',
		// 只有一个接口地址可以不填。待请求地址列表
		baseURLs: {
			lop: 'https://lop-api.vertu.com'
		},
		// 使用 baseURLs 的 key
		base: 'lop',
		onRequest: async (ctx) => {
			ctx.options.headers = { token: 'token' };
		},
		onError: async (ctx) => {
			console.log('请求错误', ctx);
		}
	});
	request.get('url', {});
	request.post('url', {});
	request.put('url', {});
	request.patch('url', {});
	request.delete('url', {});

Readme

Keywords

none

Package Sidebar

Install

npm i @vuni/request

Weekly Downloads

0

Version

0.0.2

License

none

Unpacked Size

9.81 kB

Total Files

8

Last publish

Collaborators

  • vuni