Skip to content
This repository was archived by the owner on Sep 26, 2022. It is now read-only.

Adding support for posting json arrays.#128

Merged
thomasvidas merged 4 commits intocapacitor-community:1.1.0from
milanc:master-json-array-support-v1
Jun 25, 2021
Merged

Adding support for posting json arrays.#128
thomasvidas merged 4 commits intocapacitor-community:1.1.0from
milanc:master-json-array-support-v1

Conversation

@milanc
Copy link
Contributor

@milanc milanc commented May 28, 2021

Android:

  • Array request support
  • Removing the extra new line from the plain text responses.
  • Adding error property to response sent from plugin.

ios:

  • Array request support - there is probably better solution (maybe pushing plugin call variable down through methods) but this also works. As I am not experienced with swift tried to do as less mods as possible.
  • There was no extra new line issue
  • I did not include error property for ios as existing implementations in ios and android are not the same (as I can see).

Thing to consider:

I don't have experience with java/swift but as I understood the code response implementations are not the same:

  • Android plugin resolves (call.resolve) http errors - reads error stream and returns json object from readData
  • ios plugin rejects (call.reject) http errors - if error occurs plugin call result is empty
  • Android plugin has {"ok":false} for http errors but ios does not have the same field.

I hope this make sense.

@yacut
Copy link

yacut commented Jun 8, 2021

Any update on this?

@milanc
Copy link
Contributor Author

milanc commented Jun 9, 2021

Waiting for someone to approve PR.
If you need this functionality you can use files from this PR and patch node_modules after the installation.
Make sure it does not conflicts with the latest version from npm.

This is what we have in package.json

{
        "patch:android:http:plugin": "cp ./android/http-fix/*.* ./node_modules/@capacitor-community/http/android/src/main/java/com/getcapacitor/plugin/http",
        "patch:ios:http:plugin": "cp ./ios/http-fix/*.* ./node_modules/@capacitor-community/http/ios/plugin"
}    

Can call these from npm "postinstall" script.

Copy link
Contributor

@thomasvidas thomasvidas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 Good addition 😄

@thomasvidas thomasvidas changed the base branch from master to 1.1.0 June 25, 2021 21:33
@thomasvidas thomasvidas merged commit b78dd2b into capacitor-community:1.1.0 Jun 25, 2021
@thomasvidas thomasvidas mentioned this pull request Jul 15, 2021
thomasvidas added a commit that referenced this pull request Jul 15, 2021
* feat: Add support for CJS
* feat(android): Set "GET" as default HTTP function in `downloadFile` function
* feat(android):  Updated downloadFile method on RequestHandler to use GET by default
* feat: Adding support for posting json arrays. (#128)
* Android - Prevent extra new line in text response.
* Android - Support json array requests.
* Android - Add error property on JSObject output.
* ios - Support array request.
* feat(web): Add additional logic for FormData typed request bodies (#126)
* fix(android): fix bug on android when receiving plain boolean values (#145)
* feat(iOS) Fix: Allow non-object request bodies (#141)
* feat: implement getRequestDataAsMultipartFormData
* fix: allow non-object http body
* feat(iOS): Add fallback to always try to parse the request data no matter the content type
* feat(iOS): implement getRequestDataAsMultipartFormData (#139)
* fix(android): Allow non-object request bodies (#143)
* feat: implement getRequestDataAsMultipartFormData
* fix: allow non-object http body
* feat(iOS): Add fallback to always try to parse the request data no matter the content type
* feat(android): non-object post body
* fix: bug where httpconn was being written to after it was closed
* fix(android): add in missing get, post, put, patch, and del functions to public API
* fix(ios): Publicly expose get, post, put, patch, del functions on Http plugin object
* chore(example): Update example project lockfiles
* fix(android): Fix issues with timeouts and remove unused imports
* chore: Cleanup .gitignore
* chore: Bump version to 1.1.0

Co-authored-by: ultimate-tester <ultimate-tester@users.noreply.github.com>
Co-authored-by: Joel Nieto <joelnietotec@outlook.com>
Co-authored-by: Adrian Sanchez <sgzadrian@gmail.com>
Co-authored-by: milanc <8333458+milanc@users.noreply.github.com>
Co-authored-by: herecoulbeyourname <57253976+herecoulbeyourname@users.noreply.github.com>
Co-authored-by: Frank608 <56638143+Frank608@users.noreply.github.com>
Co-authored-by: Emily Curry <emily@curry.sh>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants