Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
const axios = require('axios'); //remember to install the axios npm
var url = 'https://{SERVER}{LIST ID}/members';
var api_key = '{API KEY HERE}';
export function createSub(fname, lname, email) {
return axios({
url: url,
method: 'post',
headers: {
'Authorization': 'Basic ' + api_key,
'Content-Type': 'application/json'
data: JSON.stringify({
email_address: email,
status: 'subscribed',
merge_fields: {
FNAME: fname,
LNAME: lname
.then( (response) => {
return {status: response.status, response:};
.catch( (error) => {
return {status: error.response.status, response:};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment