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

Server rendering is broken #361

Closed
joxerTMD opened this issue Feb 9, 2018 · 4 comments
Closed

Server rendering is broken #361

joxerTMD opened this issue Feb 9, 2018 · 4 comments

Comments

@joxerTMD
Copy link

joxerTMD commented Feb 9, 2018

The what-wg polyfill you use is not isomorphic , so when i try to render my app on node server it fails with the following mistake: 'ReferenceError: Headers is not defined' on this line.

  1. Why do you use so strange assignment in module definition? Can you remove it or make some another workaround?
  2. I'm currently using Headers polyfill on my server as a workaround, but it would be great if you can fixit on your side.
    Thanks! :)
@joxerTMD joxerTMD changed the title Can't render my formio application on server Server rendering is broken in formio application Feb 9, 2018
@joxerTMD joxerTMD changed the title Server rendering is broken in formio application Server rendering is broken Feb 9, 2018
@travist
Copy link
Member

travist commented Mar 9, 2018

I agree this needs to be fixed. I am not sure why the Headers is assigned that way, but I assume it is done to support some legacy function. This library was built specifically for the front end, and if you want to have a similar function to server side function, then I would recommend using the https://github.com/formio/formio-service since it is built for Node.js and uses Request node module which is much better than our polyfill.

@dylanized
Copy link

I am struggling with this too, but in our scenario we don't have a username and password available - we just have a jwt token. Is there any way to pass the token into formio-service?

@travist
Copy link
Member

travist commented Mar 13, 2018

Yes, just pass the key with the configuration.

var formio = require('formio-service')({
  key: '[YOUR API KEY]'
});

// Create a new form instance.
var form = new formio.Form('https://myapp.form.io/user');

// Iterate through all the submissions.
form.eachSubmission(function(submission) {

  // Console log the submissions.
  console.log(submission);
});

@travist
Copy link
Member

travist commented Mar 13, 2018

Just added some docs to help with that.

https://github.com/formio/formio-service

@travist travist closed this as completed Mar 13, 2018
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

No branches or pull requests

3 participants