请问:小程序在前端用wx.request({url: url,
method: "POST",
json: true,
header:{'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'},
formData: formData,,}) 请求第三方的登陆接口,从res.header['Set-Cookie']可以获取SESSIONID,但用云函数请求时只获取其它数据,没有响应头,即找不到res.header,请教有办法在云函数中获取?
const cloud = require('wx-server-sdk') const axios = require('axios/dist/node/axios.cjs'); const request = require('request-promise'); cloud.init({ env: '**********'}) exports.main = async (event, context) => { return new Promise((resolve, reject) => { const url = 'https://***.cn//validpassword' const headers = { 'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8'} const formData = { username: '123456', password: 'szcode2024'} request({ url: url, method: "POST", json: true, headers, //必须加 formData }).then(resp=>{ console.log(resp) }).catch(error=> { console.log(error); }) }) }) 前端获取打印RES {accelerateType: "none" cookies: (2) ["name=value; path=/; Secure; HttpOnly", "SESSION=001a1b74-2015-49de-5621-rds468ht130f; Path=/eUrbanMIS/; HttpOnly"] data: {resultInfo: {…}} errMsg: "request:ok" header: {Server: "openresty/1.19.3.1", Date: "Tue, 07 May 2024 08:49:26 GMT", Content-Type: "application/json;charset=UTF-8", Transfer-Encoding: "chunked", Connection: "keep-alive", …} statusCode: 200} __proto__: Object 云函数打印的只有data: {resultInfo: {…}}这一部分