salary-management-front/pc4mobx/hrmSalary/util/request.js

26 lines
741 B
JavaScript
Raw Normal View History

2022-03-23 19:38:10 +08:00
export const formPost = (url, params) => {
2022-03-30 20:04:34 +08:00
url = url + "?__random__=" + (new Date()).valueOf();
2022-03-23 19:38:10 +08:00
let formdata = new URLSearchParams();
Object.keys(params).map(key => {
formdata.append(key, params[key])
})
return fetch(url, {
method:"POST",
headers:{
"Content-Type":'application/x-www-form-urlencoded'
},
body:formdata
}).then(res => res.json())
2022-03-30 20:04:34 +08:00
}
export const postFetch = (url, params) => {
url = url + "?__random__=" + (new Date()).valueOf();
return fetch(url, {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
}).then(res => res.json())
2022-03-23 19:38:10 +08:00
}