Skip to content

Instantly share code, notes, and snippets.

@navio
Last active August 12, 2023 02:38
Show Gist options
  • Save navio/59305c42830581cc07fb566d94276d96 to your computer and use it in GitHub Desktop.
Save navio/59305c42830581cc07fb566d94276d96 to your computer and use it in GitHub Desktop.
Fetch Example application/x-www-form
let customSearch = (params) => {
let url = '/contentlicenseajax';
let body = Object.keys(params)
.map((key) => { return encodeURIComponent(key) + '=' + encodeURIComponent(params[key]); })
.join('&');
return fetch('/contentlicenseajax', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' },
credentials: 'include',
body: body
})
.then(res => res.json()).catch(res => Promise.fail({error:res}));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment