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

add Docuseal (requires text/plain support or hack) #847

Closed
meonkeys opened this issue Dec 21, 2024 · 3 comments · Fixed by #851
Closed

add Docuseal (requires text/plain support or hack) #847

meonkeys opened this issue Dec 21, 2024 · 3 comments · Fixed by #851

Comments

@meonkeys
Copy link
Contributor

Docuseal now exposes its version at /version, but the response is a text/plain string like 1.8.3a, not JSON. Can Homer somehow use this as-is?

I tried creating a custom service / smart card like the others I've made, but I get SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 4 of the JSON data in the console.

I tried manually adding double quotes around the response, making it "1.8.3a"...

this.versionstring = '"' + response + '"';

then Homer accepts the string, but it prints Version "1.8.3a" on the smart card (with double quotes).

@bastienwirtz
Copy link
Owner

Hello @meonkeys !

I assume you got the parse error using the this.fetch method ? did you try using it with the third parameter to false?

// fetch: function (path, init, json = true) -> the json parameter will activate or not the json parsing
this.fetch('http://your-url', null, false);

@meonkeys
Copy link
Contributor Author

meonkeys commented Dec 23, 2024

Oh nice, that helps, thank you.

Looks like fetch() in the "service" mixin needs a little patch, though:

diff --git a/src/mixins/service.js b/src/mixins/service.js
index b4fd2ad..7051a8f 100644
--- a/src/mixins/service.js
+++ b/src/mixins/service.js
@@ -56,7 +56,7 @@ export default {
           throw new Error(`Ping: target not available (${response.status} error)`);
         }
 
-        return json ? response.json() : response;
+        return json ? response.json() : response.text();
       });
     },
   },

Without that I'm getting Version "[object Response]" on the smart card.

Want a PR for that? Separate PR, I assume? ... see #850

meonkeys added a commit to meonkeys/homer that referenced this issue Dec 29, 2024
Without that I'm getting Version "[object Response]" on the smart card
from an api that returns text/plain.

See bastienwirtz#847 - add Docuseal (requires text/plain support or hack)
meonkeys added a commit to meonkeys/homer that referenced this issue Dec 29, 2024
@meonkeys meonkeys mentioned this issue Dec 29, 2024
7 tasks
@bastienwirtz
Copy link
Owner

Good catch @meonkeys ! The response body wihtout json parsing has never been used (the ping component use the third parameter to false, but it does not use the response).
And no worries for the the PR, in the same one is fine.

bastienwirtz pushed a commit that referenced this issue Jan 5, 2025
Without that I'm getting Version "[object Response]" on the smart card
from an api that returns text/plain.

See #847 - add Docuseal (requires text/plain support or hack)
bastienwirtz pushed a commit that referenced this issue Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants