-
Notifications
You must be signed in to change notification settings - Fork 122
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
Component parameters are ignored when doing backend-rendering with oc-client nodejs library #431
Comments
All seems correct on a first look. What's the output of html? Can you console.log that and see what contains? |
Given the next template: <div id="widget-selector"></div>
<script src="{{staticPath}}build/static/js/main.js"></script>
<script>
// Instantiating widget, passing the selector where
// you want to render it, and som parameters to configure it
Instance = SomeWidget.default.widget.new({
selector: "#some-selector",
apikey: '{{params.apikey}}'
});
Instance.render();
</script> The otuput of server-rendering is (changing sensitive values): <div id="widget-selector"></div>
<script src="//s3-eu-west-1.amazonaws.com/xxxxxxxx/components/xxxx-xxxxx/0.5.0/build/static/js/main.js"></script>
<script>
// Instantiating widget, passing the selector where
// you want to render it, and some parameters to configure it
Instance = SomeComponent.default.widget.new({
selector: "#widget-selector",
apikey: ''
});
Instance.render();
</script>
<script>window.oc=window.oc||{};oc.renderedComponents=oc.renderedComponents||{};oc.renderedComponents["some-component"]="0.5.0";</script> And using curl with querystring: <oc-component href=\"https://xxxxxx/some-component?apikey=1234\" data-hash=\"97c8daed7d56f05aa163e0d67356c50c5631227b\" data-name=\"some-component\" data-rendered=\"true\" data-version=\"0.5.0\"><div id=\"widget-selector\"></div>\n<script src=\"//s3-eu-west-1.amazonaws.com/xxxxxxxx/components/some-component/0.5.0/build/static/js/main.js\"></script>\n<script>\n // Instantiating widget, passing the selector where\n // you want to render it, and som parameters to configure it\n Instance = SomeCompnent.default.widget.new({\n selector: \"#some-component\",\n apikey: '1234'\n });\n Instance.render();\n</script>\n<script>window.oc=window.oc||{};oc.renderedComponents=oc.renderedComponents||{};oc.renderedComponents[\"some-component\"]=\"0.5.0\";</script></oc-component> |
@gtrias try to add also // cc @matteofigus |
Definitely looks like a bug. |
@mattiaerre Adding oc-client to the components collections did the trick!! Now it works as expected :) |
From what I see here, it may be related to #347 |
@gtrias it is even more than that tbf. If there is one component w/ parameters the output is empty. If there is one component w/o parameters it works. as per @matteofigus note, we will look into this issue. |
I'm trying to send parameters to component in order to perform the backend rendering. Given the next component array:
The component is rendered but not receiving the parameter apikey. By the other hand if I request the component using curl and passing the parameter as a querystring the widget is taking it properly.
Am I missing anything?
oc-client version: ^2.1.6
oc registry version: 0.36.15
My current implementation is the next:
Component
server.js
:template.html
Server side rendering:
The text was updated successfully, but these errors were encountered: