Skip to content

Output with headers: [object Object] when --debug specified on multiple locations #108

@VelinGeorgiev

Description

@VelinGeorgiev

We have that piece of code on multiple locations:

        if (this.debug) {
          cmd.log('Executing web request...');
          cmd.log(requestOptions);
          cmd.log('');
        }

But whenever requestOptions has headers specified like:

const requestOptions: any = {
          ...
          headers: Utils.getRequestHeaders({
            authorization: `Bearer ${accessToken}`,
            accept: 'application/json;odata=nometadata'
          })
        };

then the output for the headers section when we specify --debug is

Executing web request...
url    : https://xxx.sharepoint.com/sites/xxx/_api/contextinfo
headers: [object Object]
json   : true

This can be changed to

    if (this.debug) {
      cmd.log('Executing web request...');
      cmd.log(JSON.stringify(requestOptions));
      cmd.log('');
    }

to print the correct output.

I did not wanted to change it before discussion because it has 24 occurrences in the solution.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions