Node API to update a field of a subscriber

SoftTimur

Member
(* I understand that node-mialwizz is not your library, but your experience with PHP SDK may help *)

I tried to use the following code to update `TRANSACTIONAL_REMINDERS` of `aoxiang.paris@gmail.com` (whose id is `gx661wf91q518`):

JavaScript:
const { ListSubscribers } = require('node-mailwizz');
const config = {
    publicKey: 'key',
    secret: 'key',
    baseUrl: 'http://mail.mycompany.com/api'
}

const subscribers = new ListSubscribers(config);

function updateSubscriber() {
    const userInfo = { EMAIL: "aoxiang.paris@gmail.com", TRANSACTIONAL_REMINDERS: "YES" };
    subscribers.update({
        listUid: "en804x0lnrf1f",
        subscriberUid: "gx661wf91q518",
        userInfo: userInfo
    }).then(result => {
        console.log('Subscriber updated:', result);
    }).catch(err => {
        console.error('Error:', err);
    })
}

updateSubscriber();

It returned

```
Subscriber updated: {
status: 'success',
data: {
record: {
subscriber_uid: 'gx661wf91q518',
email: 'aoxiang.paris@gmail.com',
ip_address: '74.125.209.68',
source: 'import',
date_added: '2023-10-15 08:37:23'
}
}
}
```

However, when i check it on the website of MailWizz, the field `TRANSACTIONAL_REMINDERS` is still empty.

Does anyone know what's the correct way to update a field of a subscriber by API in node?
 
Last edited:
(* I understand that node-mialwizz is not your library, but your experience with PHP SDK may help *)

I tried to use the following code to update `TRANSACTIONAL_REMINDERS` of `aoxiang.paris@gmail.com` (whose id is `gx661wf91q518`):

JavaScript:
const { ListSubscribers } = require('node-mailwizz');
const config = {
    publicKey: 'key',
    secret: 'key',
    baseUrl: 'http://mail.mycompany.com/api'
}

const subscribers = new ListSubscribers(config);

function updateSubscriber() {
    const userInfo = { EMAIL: "aoxiang.paris@gmail.com", TRANSACTIONAL_REMINDERS: "YES" };
    subscribers.update({
        listUid: "en804x0lnrf1f",
        subscriberUid: "gx661wf91q518",
        userInfo: userInfo
    }).then(result => {
        console.log('Subscriber updated:', result);
    }).catch(err => {
        console.error('Error:', err);
    })
}

updateSubscriber();

It returned

```
Subscriber updated: {
status: 'success',
data: {
record: {
subscriber_uid: 'gx661wf91q518',
email: 'aoxiang.paris@gmail.com',
ip_address: '74.125.209.68',
source: 'import',
date_added: '2023-10-15 08:37:23'
}
}
}
```

However, when i check it on the website of MailWizz, the field `TRANSACTIONAL_REMINDERS` is still empty.

Does anyone know what's the correct way to update a field of a subscriber by API in node?
Solved. It should be `data: userInfo` rather than `userInfo: userInfo`:

JavaScript:
subscribers.update({
        listUid: "en804x0lnrf1f",
        subscriberUid: "gx661wf91q518",
        data: userInfo
    })
 
Last edited:
Back
Top