4

I am trying to display a string on multilines with \n in the Postman Console. How can I do this?

Example:

var mystr='line\n another line\n another line';
console.log(mystr);

Expecting:

line
another line
another line

Getting:

lineanother lineanother line

Note: it is working as expected in Firefox scratchpad.

Maak
  • 4,720
  • 3
  • 28
  • 39
mitul jain
  • 61
  • 1
  • 5

4 Answers4

2

Postman console log not allowing to write string in next line #1477

Asked the same question on postman GitHub, I will update here once got the solution.

Thanks, @Danny Dainton :)

n-verbitsky
  • 552
  • 2
  • 9
  • 20
mitul jain
  • 61
  • 1
  • 5
2

type 3 times console.log:

console.log('linea1');
console.log('linea2');
console.log('linea3');
2

You can print multiline text like this:

console.log("hello", '\n', "world");

Which will show up like this in console:

enter image description here

Jenny
  • 572
  • 4
  • 16
1

I don’t think that you can achieve this in the Postman console - maybe worth raising an issue on the Postman github project, is there isn’t one already.

I would have suggested doing the same thing as the comments, adding \n works in every other console but this one, which is strange.

I think that the only way, at the moment, is just to add multiple console.log() statements, to get your vars printing on new lines.

Another alternative is to put what you need into an array - This is not ideal but would give you the information in the console, on separate lines.

Postman Console

Danny Dainton
  • 23,069
  • 6
  • 67
  • 80
  • 1
    Using the array prints the leading `0: ` line number each time, which prevents copying the printed lines. – bastelflp Oct 17 '18 at 17:24