Error during processing request
-
Hi, i'm trying to follow the Custom Recipe Guide.
but when i run a sample report with html-to-text i recevice the error:TypeError [ERR_HTTP_INVALID_HEADER_VALUE]: Invalid value "undefined" for header "Content-Type"
at ServerResponse.setHeader (_http_outgoing.js:561:3)
at /var/progettinodejs/jsreport-extension-starter-kit/node_modules/jsreport-express/lib/routes.js:44:11
-
hi @alemrsrl
i think the custom recipe needs an update, for example this part:
reporter.extensionsManager.recipes.push({ name: 'html-to-text', execute: (request, response) => { response.content = new Buffer(convert.fromString(response.content.toString(), { wordwrap: (request.template.htmlToText || {}).wordWrap || 130 })) } })
needs to set also some meta data about the report like this:
reporter.extensionsManager.recipes.push({ name: 'html-to-text', execute: (request, response) => { response.content = new Buffer(convert.fromString(response.content.toString(), { wordwrap: (request.template.htmlToText || {}).wordWrap || 130 })) response.meta.contentType = 'text/plain' response.meta.fileExtension = 'txt' } })
of course you should set the
contentType
andfileExtension
, depending of the type of content the recipe produces, for this case, the recipe produces text so that is why we use the values shown above.hope it helps, we are going to update the guide
-
Thanks, i will try this soloution soon.