Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding complex object to request().field() method #842

Open
2 of 3 tasks
swkang0513 opened this issue Jul 9, 2024 · 3 comments
Open
2 of 3 tasks

Adding complex object to request().field() method #842

swkang0513 opened this issue Jul 9, 2024 · 3 comments
Labels

Comments

@swkang0513
Copy link

Describe the bug

Node.js version: 18.18.2

OS version: macOS Sonoma 14.4

Description:

When adding complex object to field() method, the documentation says to use it like this. #759

.field('complex_object', '{"attribute": "value"}', {contentType: 'application/json'})

With this solution, I got an error.

Expected 1-2 arguments, but got 3.ts(2554)

@types/supertest 6.0.2
supertest 7.0.0
typescript 5.4.5

Actual behavior

await request(app)
  .post('/test')
  .field('myObject', JSON.stringify({ key1: 'key1', key2: 'key2' }), { contentType: 'application/json' })
  .attach('attachments', path.join(__dirname, 'image.png'))
  .expect(200)

Expected behavior

Test success without an error.

Code to reproduce

Checklist

  • I have searched through GitHub issues for similar issues.
  • I have completely read through the README and documentation.
  • I have tested my code with the latest version of Node.js and this package and confirmed it is still not working.
@swkang0513 swkang0513 added the bug label Jul 9, 2024
@j-elmer123
Copy link

I got similar issue where I can't put { contentType: 'application/json' } in the third param.

@j-elmer123
Copy link

I got similar issue where I can't put { contentType: 'application/json' } in the third param.

just realized seems we need to add the options params in the superagent types repo. I just added here, feel free to add feedback that I required to do. This is the first time I try to update open source repo. not sure if I did it correctly.

DefinitelyTyped/DefinitelyTyped#70050

@j-elmer123
Copy link

I got similar issue where I can't put { contentType: 'application/json' } in the third param.

just realized seems we need to add the options params in the superagent types repo. I just added here, feel free to add feedback that I required to do. This is the first time I try to update open source repo. not sure if I did it correctly.

DefinitelyTyped/DefinitelyTyped#70050

just wanted to let @swkang0513 know the PR already approved and merged, so it should solve the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants