Struggling to write response to a file

Still new to a k6.
Struggling to write response to a file .
Running following code

import http from "k6/http";
import { check } from "k6";
import { parseHTML } from 'k6/html';

export const options = {   vus: 1,  iterations: 1,  httpDebug: 'full',  }

//
  export default function () {
    let the_url;
    the_url = 'https://k6.io/';
    
    getResponse(the_url);
  }

//
export function getResponse(the_url){
  const res = http.get(the_url);
  const doc = parseHTML(res.body); // equivalent to res.html()
  console.log('\tDBG: '+  doc);
}

outputting the response to a file k6 run ./_eg-.js 2>./logs/resp.html
i need to see the HTML file
getting large html file

6 : time="2022-11-30T22:20:35-05:00" level=info msg="Request:
GET / HTTP/1.1
Host: k6.io
User-Agent: k6/0.41.0 (https://k6.io/)
Accept-Encoding: gzip

" group= iter=0 request_id=c65a8c1a-fee7-4c89-573d-35540e8592f0 scenario=default source=http-debug vu=1 At line:1 char:1 + k6 run ./_eg-.js 2>./logs/resp.html + + CategoryInfo : NotSpecified: (time="2022-11-3...http-debug vu=1:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError time="2022-11-30T22:20:35-05:00" level=info msg="Response:
HTTP/2.0 200 OK
Content-Length: 498970
Age: 200900
Cache-Control: public, max-age=0, must-revalidate
Content-Type: text/html
Date: Mon, 28 Nov 2022 19:32:15 GMT
Etag: \"6734b9991402efbc87193ec834b1109d\"
Last-Modified: Mon, 28 Nov 2022 17:36:48 GMT
Server: AmazonS3
Vary: Accept-Encoding
Via: 1.1 5e2f1ed3ba0ab1e08304bb3d134360de.cloudfront.net (CloudFront)
X-Amz-Cf-Id: MS4A7Rh1MDrbb90KgM29vVgJHfPV6tfWPTZ47Pkj0OchdPzAt0QHIA==
X-Amz-Cf-Pop: YTO50-P2
X-Cache: Hit from cloudfront

What do i do wrong

Hello! I can’t help yet, I’m afraid, but do you mind clarifying a few things about your use case?

  • What primary goal here? What would you do with this file?
  • Does console.log('\tDBG: '+ doc) log what you want? Maybe you could use the --log-output option to write this to a file.
  • For more complex writes, you might need to use an extension, for the reasons explained in this post Write data to file - #2 by imiric

i need it for debugging
When i am doing console.log('\tDBG: '+ doc), the result is to big.
see the attached sample.

I could able to write responses in file using xk6 command line extension.

Steps need to follow,

  1. Install GO
  2. Install xk6 extension using cmd: xk6 build v0.46.0 --with github.com/avitalique/xk6-file@latest
  3. Download Git Repo that uses xk6 extension from GitHub - avitalique/xk6-file: k6 extension for writing files
  4. run the script ./k6 run examples/sample-script.js , it will create new text as well as binary file