Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

supertest multipart/form-data

const res = await request(app)
  .post('/api/auth/register')
  .field('name', userData.name)
  .field('email', userData.email)
  .field('password', userData.password)
  .field('personalInformation[firstName]', personalInformation.firstName)
  .field('personalInformation[lastName]', personalInformation.lastName)
  .field('personalInformation[birtDate]', personalInformation.birtDate)
  .field('personalInformation[bornDate]', personalInformation.bornDate)
  .field('personalInformation[address]', personalInformation.address)
  .field('workExperinces[0][companyName]', workExperinces.companyName)
  .field('workExperinces[0][jobsPosition]', workExperinces.jobsPosition)
  .field('workExperinces[0][startWork]', workExperinces.startWork)
  .field('workExperinces[0][endWork]', workExperinces.endWork)
  .field('workExperinces[0][jobsDescription]', workExperinces.jobsDescription)
  .attach('photo', readPhoto)
  .attach('document', readDocument)
  .set('Content-Type', 'multipart/form-data')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #supertest
ADD COMMENT
Topic
Name
6+3 =