Skip to content

include not working? #10

Description

@jmbldwn

I must be missing something. I can only include startTime, categoryName, level, and data in my json output.

It appears to be because the formatter code selects the fields from output instead of data:

    // Only include fields specified in 'include' field
    // if field is specified
    if (config.include && config.include.length) {
      const newOutput = {};
      _.forEach(config.include, (key) => {
        if (_.has(output, key)) {
          newOutput[key] = output[key];
        }
      });
      return newOutput;
    }

data is set earlier as a clone of the formatter input:

  function formatter(raw) {
    const data = _.clone(raw);
...

and output specifically only selects a few fields:

    const output = {
      startTime: data.startTime,
      categoryName: data.categoryName,
      level: data.level.levelStr,
    };

It would appear that this bit of code at line 105:

        if (_.has(output, key)) {
          newOutput[key] = output[key];
        }

should be:

        if (_.has(data, key)) {
          newOutput[key] = data[key];
        }

Am I missing something? I assume I'm doing something wrong...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions