Issue with Mongo export

  • I am trying to export report data from the mongoDB store into a .jsrexport file as soon as the instance is initialized.

    const dotenv = require('dotenv');
    const jsrCore = require('@jsreport/jsreport-core');
    let config = require('./jsreport.config.json');
    config.extensions['mongodb-store'].uri = process.env.DB_URI;
    const jsreport = jsrCore(config);
    async function exportData() {
      try {
        const reportData = await jsreport.export({
          all: true,
          output: 'export.jsrexport',
        console.log('Data exported successfully.', reportData);
      } catch (err) {
        console.error('Failed to export data:', err);
    if (process.env.JSREPORT_CLI) {
      module.exports = jsreport;
    } else {
        .then(async () => {
          console.log('Report Server Started...');
          await exportData();
        .catch((err) => {
          console.error('Failed to start Report Server...', err);

    This is throwing the error "Failed to export data: TypeError: Cannot read properties of undefined (reading 'context'), I need a way to export existing MongoDB form data and programmatically import the exported file somewhere else.

  • This will work

    const reportData = await jsreport.export(null, jsreport.Request({}))

    However, note it is our internal API and may change in the future.

Log in to reply

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.