Created
December 6, 2021 05:59
-
-
Save horitaku1124/bc8dce6f32d0e0e67fd7038ef2e1548e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function postFormData(url = '', data = "") { | |
const response = await fetch(url, { | |
method: 'POST', | |
mode: 'cors', | |
cache: 'no-cache', | |
credentials: 'same-origin', | |
headers: { | |
'Content-Type': 'application/x-www-form-urlencoded', | |
}, | |
redirect: 'follow', | |
referrerPolicy: 'no-referrer', | |
body: data | |
}); | |
return response.json(); | |
} | |
postFormData('http://localhost/test', "a=1&b=2") | |
.then(data => { | |
console.log(data); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment