Skip to content

Instantly share code, notes, and snippets.

@SilencerWeb
Created February 21, 2018 11:37
Show Gist options
  • Save SilencerWeb/c80c8b34fb829c4a5202bd64928bd067 to your computer and use it in GitHub Desktop.
Save SilencerWeb/c80c8b34fb829c4a5202bd64928bd067 to your computer and use it in GitHub Desktop.
function b64EncodeUnicode(str) {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
function toSolidBytes(match, p1) {
return String.fromCharCode('0x' + p1);
}));
}
fetch('https://us17.api.mailchimp.com/3.0/lists/185415c92c/members', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Basic ${b64EncodeUnicode('silencerweb:8ec49e64f2041073d3fe56e0abc5fe5f-us17')}`,
},
body: JSON.stringify({
email_address: 'email@mail.ru',
status: 'subscribed',
}),
mode: 'no-cors',
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment