import {
	fetch
} from './request.js'

const obj = {
	headerGET: {
		"Content-type": 'application/x-www-from-urlencoded'
	},
	headerPOST: {
		"Content-type": 'application/json'
	},
}

// 通用接口请求
export const reqAll = (url, params, hideToken, opt = {}) => {
	opt.data = params
	opt.header = obj['headerPOST']
	opt.hideToken = hideToken;
	return fetch(url, opt)
}

// get请求
export const reqGet = (url, params, hideToken, opt = {}) => {
	opt.header = obj['headerGET']
	opt.method = "GET"
	opt.params = params
	opt.hideToken = hideToken;
	return fetch(url, opt)
}

// post请求
export const reqPost = (url, params, hideToken, opt = {}) => {
	opt.header = obj['headerPOST']
	opt.method = "POST"
	opt.data = params
	opt.hideToken = hideToken;
	return fetch(url, opt)
}

// put请求
export const reqPut = (url, params, hideToken, opt = {}) => {
	opt.header = obj['headerPOST']
	opt.method = "PUT"
	opt.data = params
	opt.hideToken = hideToken;
	return fetch(url, opt)
}

// delete请求
export const reqDelete = (url, params, hideToken, opt = {}) => {
	opt.header = obj['headerGET']
	opt.method = "DELETE"
	opt.params = params
	opt.hideToken = hideToken;
	return fetch(url, opt)
}
