Bad Request 400 when trying to send pubsub message from EBS - Node.js

Here is my code :

const EXT_SECRET = Buffer.from('mYSecreT=', 'base64'); 

router.post('/message', (req, res) => {
    const { channelId, clientId, userId } = req.body.auth;
    fetch(`https://api.twitch.tv/extensions/message/${channelId}`, {
        method: 'POST',
        headers: {
            'Authorization': `Bearer ${makeServerToken(channelId, userId)}`,
            'Client-Id': clientId,
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({
            content_type: 'application/json',
            message: { foo: 'bar' },
            targets: ['broadcast']
        })
    })
        .then(response => response.json())
        .then(response => {
            console.log(response);
        })
        .catch(err => { console.log(err) });
});

function makeServerToken(channelId, userId) {
    const payload = {
        exp: Math.floor(Date.now() / 1000) + 30,
        channel_id: channelId.toString(),
        user_id: userId.toString(),
        role: 'external',
        pubsub_perms: {
            send: ['broadcast']
        }
    };
    return jwt.sign(payload, EXT_SECRET, { algorithm: 'HS256' });
}

Here is the error I am getting:

{ error: 'Bad Request',
  status: 400,
  message: 'Missing required parameter "message"' }

On my side I make sure that the message parameter is always a string.
In the documentation you can see that the message content has been encoded as a string itself.

So in your case you should change the value of message to

message: JSON.stringify({ foo: ‘bar’ })

Thanks!