I'm writing a unit test with supertest to test my server. But one of my body fields containing an array of json objects 'arrives' undefined.
the code:
//declaration of variable
tags = [{name: 'tag1'},{name: 'tag2'},{name: 'tag3'}];
//actual post
agent.post('/pictures')
.set('Connection', 'keep alive')
.set('Content-Type', 'application/x-www-form-urlencoded')
.field('picTitle', 'Picture Title')
.field('tags', tags)
.attach('file', __dirname + '/img/noel.jpg')
.end(function(pictureSaveErr, pictureSaveRes) {
//do stuff
}
So the problem is that req.body.tags at the server is undefined. Strings are no problem. The actual implementation with angular frontend is working perfectly so the problem isn't with the server.
Hope someone can help me out, a big thanks in advance...
Aucun commentaire:
Enregistrer un commentaire