类型 'string[]' 不可分配给 nestjs 中的类型 'string'

Type 'string[]' is not assignable to type 'string' in nestjs

我正在尝试通过在 nestjs 中调用外部 API 来下载文件。 下面是我的服务代码

import { Injectable } from '@nestjs/common';
import * as fs from "fs";
import * as axios from "axios";
@Injectable()
export class FileService {
  saveFile() {
    return axios.default
      .get("https://www.nseindia.com/")
      .then((res) => {
        return axios.default.get(
          "https://www.nseindia.com/api/option-chain-indices?symbol=BANKNIFTY",
          {
            headers: {
              cookie: res.headers["set-cookie"],
            },
          }
        );
      })
      .then((res) => {
        //console.log(res.data);
        let data = JSON.stringify(res.data);
        fs.writeFileSync("../files/option-chain-indices.json", data);
        return data;
      })
      .catch((err) => {
        console.log(err);
      });
  }
}

我收到如下错误

error TS2322: Type 'string[]' is not assignable to type 'string'.

cookie: res.headers['set-cookie']

我该如何解决这个问题?

你能把下面这行代码改成下面这样吗?

cookie: res.headers["set-cookie"] --> cookie: res.headers["set-cookie"].join(';')