ga2mer / ha-zepp

Home Assistant companion for Zepp OS devices
71 stars 19 forks source link

Split resource from options in fetch function #9

Closed joserebelo closed 1 year ago

joserebelo commented 1 year ago

I am not sure how this works in the modified Zepp App, as I do not have it, but while trying to run this on Gadgetbridge, and even locally, I ran into the following issue:

Fetch API cannot load file:///android_asset/zepp_os/[object%20Object]. URL scheme "file" is not supported. (at unknown: 1)

It looks like the object is being stringified as a URL, resulting in a failed request.

This PR splits the url from the options, which should fix the issue. I have not been able to fully test this, as Gadgetbridge support is still not fully working, but I see the GET request hitting the server correctly.

ga2mer commented 1 year ago

This will probably break app, since Zepp (not even the modified one) app-side fetch has its own implementation and has one argument with URL string for GET request and settings object for POST and the url needs to be specified in it

https://docs.zepp.com/docs/reference/side-service-api/fetch/

If possible, it is better to make a global variable that allows you to understand in which runtime the app-side is running or repeat the implementation as in Zepp

joserebelo commented 1 year ago

I marked this PR as draft, but I should have actually closed it.

Makes no sense to do changes to the app if it already works on the official app - and I missed that fetch override, thanks.

I will update Gadgetbridge to override the fetch function as well.