Error 415 - Unsupported Media Type

I am tryin to send a json object feedData to the server. This object has a File Object inside of it.

feedData = {
    'title' : 'some title',
    'type' : 1,
    'feedBody' : {
        'image' : File Object {lastModified : xxxx, name : 'image.jpg', type: 'image/jpg', ... }
    }
}

return fetch(`/api/feeds/${feedId}/create`, {
    method: 'POST',
    body: JSON.stringify(feedData),
    headers: {
        'Authorization': getTokenHeader(token),
    },
})

In routes I have

method: 'POST',
path: '/api/feeds/{feed}/create',
config: {
    payload: {
        output: 'stream',
        parse: true,
        allow: ['application/json', 'multipart/form-data', 'image/jpeg', 'application/pdf', 'application/x-www-form-urlencoded'],
        maxBytes: 1024 * 1024 * 100,
        timeout: false
    },
    handler: (req, res) => {
        const params = { token: req.auth.token, ...req.params };
        const payload = req.payload;
        console.log('HAPI ', payload);
    },
    auth: {
        strategy: 'jwt-strict',
        mode: 'required'
    }
}

I get back an error

http://localhost:3000/api/feeds/feed/create 415 (Unsupported Media Type)

What am I doing wrong?

#nodejs #node #javascript

41.80 GEEK