26 lines
741 B
JavaScript
26 lines
741 B
JavaScript
export const formPost = (url, params) => {
|
|
url = url + "?__random__=" + (new Date()).valueOf();
|
|
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())
|
|
}
|
|
|
|
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())
|
|
} |