-
Notifications
You must be signed in to change notification settings - Fork 471
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
Hoodie Client + React Native #732
Comments
Hey @alterx, thanks for the kind words! Cool that you give Hoodie a try with a React Native app, there were others expressing interest in that combination, hope you can share your setup once you have it working, we are happy to help! We use I’ve no experience with React Native myself. Could you check if others successfully implemented JSON API with a React Native app? Maybe they found a workaround? |
Oh, I see. Yeah, now it makes sense. Thanks for the quick response @gr2m I think I just discovered the root cause of the issue, it looks like Android somehow adds a media type parameter to the |
It looks like the issue goes deeper than I thought, probably into the native android code. There's and open issue in the react native repo facebook/react-native#8237 (comment) and I've added some details. For the time being the only solution seems to add something like this
and spin off a custom hapi server that uses the rest of the |
you can add a custom module.exports = function (server, options, next) {
server.ext('onRequest', function (request, reply) {
if (request.headers['content-type'] && request.headers['content-type'].indexOf('application/vnd.api+json') !== -1) {
request.headers['content-type'] = 'application/vnd.api+json'
}
reply.continue()
})
} But note that you only want the requests to be affected that start with If this is a known issue on Android OS level, I also wouldn’t mind to not fully comply to the JSON API specification and also accept |
For the time being I'll just stick with the custom extension until I get a word about this being an Android issue. @gr2m, is there a preferred way to distribute this custom extension? Or should I just add it to my hoodie |
we are very close to enabling 3rd-party-plugins, you can follow the status at hoodiehq/camp#104. Until then, you can put the extension in your own app, not in the |
Perfect, I'll do that then and will keep an eye on the third-party plugins. Should we keep this issue open until there's an "official" way of integrating RN and Hoodie or figure out if this truly is an Android issue? |
yeah I’d keep that issue open for others that look into React Native & Hoodie, thanks :) |
Hey @alterx, just wanted to let you know that we (silently) shipped 3rd party plugins: http://docs.hood.ie/en/latest/guides/plugins.html Would love to hear what you came up with. I’d love to look into Hoodie/react (native) myself soon |
So cool, @gr2m ! This also means that I can start working on hoodiehq/faq#142 😄 |
Nice! Looking forward to learn more :) |
Here's my first attempt, @gr2m : Let me know what you think. |
First of all, thank you all for such an amazing tool 💯
I'm building an app that I want to be resilient when dealing with adverse network conditions and I think Hoodie is the right choice so I've been trying to integrate the Hoodie client with React Native but I keep getting these
415 Unsupported Media Type
errors. One possible fix (that works for me) is to useapplication/json
as aContent-Type
in@hoodie/account-client/utils/request.js
but I'm not familiar enough with Hoodie to tell if we can do that without breaking the client for other platforms (web).Is there any reason why
@hoodie/account-client/utils/request.js
usesapplication/vnd.api+json
instead ofapplication/json
as aContent-Type
?Thanks
The text was updated successfully, but these errors were encountered: