关于前端跨域问题设置withCredentials

在不同写法下,不知道该把withCredentials:true这句放哪?应该怎么写?

//第一种情况
 getCode(){
          let api = "https://elm.cangdu.org/v1/captchas";
          this.$http({
            url:api,
            method:"post",
          //    用于用户代码是否应该在请求情况下,向其它域发送cookie,不使用缓存数据
           withCredentials:true,
            data:{
            }
          }).then((res)=>{
              console.log(res.data);
              this.code = res.data.code;
          })
      },

//第二种情况
async getCode() {
      const {data:res} = await this.$http.post({
        url:'v1/captchas',
        xhrFields:{
          withCredentials:true
        }
        });
      // console.log(res);
      //  withCredentials:true,
        this.code = res.code;
    },

第一种情况写法是正确的,对于第二种用到async/await的情况,不知道该如何处理withCredentials:true,请教大家。