Home > Net >  How to make newline writing in my case? TS
How to make newline writing in my case? TS

Time:09-28

I have that piece of code:

let list: Array<string> =[]; 
    
    page.on('request', request =>      list.push('>>', request.method(), request.url() '\\n'));  
    page.on('response', response =>       list.push('<<',String( response.status()), response.url() '\\n'));

I'm trying to divide that pushes into separated lines, but unsuccessfully. My goal is to write these strings in new lines and save it to JSON in that view. Or just to rebuild the JSON to get that view.

What do I have now: enter image description here

What am I trying to get:

enter image description here

Could you help me please with that?

CodePudding user response:

Generally use \n for line break. \\n not work.

Not know if is you case.

CodePudding user response:

Try using template literals with the backtic character (`) instead of single quotes (')

  • Related