请求路径
Promise
详细配置一个request实例
脚本举例
import { getIns } from '@tomato-js/request'
const myRequest = getIns({
responseInterceptors: [
{
onFulfilled: response => {
response.data.hello = "me";
return response;
},
onRejected: error => {
return Promise.reject(error);
}
}
]
});
const response = await myRequest.post("/post.json", {
option: "lala"
});
配置,和axios保持一致
request实例
简易post方法
脚本举例
import { post } from '@tomato-js/request'
const { data } = await post('/api.json',{
data: {
str: 'str'
}
});
请求路径
配置,和axios保持一致
Promise
全量request方法
脚本举例
import { request } from '@tomato-js/request'
const { data } = await request({
method: "get",
url: "/get.json"
});
Promise
Generated using TypeDoc
简易get方法
脚本举例
import { get } from '@tomato-js/request' const { data } = await get('/api.json');