我想将 Payload /Request body 传递给 apisauce

问题描述

嗨,我正在使用 applesauce 进行 API 调用。我想将请求正文添加到请求中。我将正文添加为最后一个代码,但它不起作用。我从 apisauce 创建 authSauace 如下。

import { create } from "apisauce";
import { AUTHORIZATION } from "../constants/commonStrings";
export const authSauce = create({  baseURL: process.env.REACT_APP_AUTH_BASE,});
export const setHeadersForAllInstances = (token) => {   authSauce.setHeader(AUTHORIZATION,`Bearer ${token}`);

};

然后我想添加如下有效载荷

authSauce
        .get(`/api/query`,null,{
            payload: {}},{
            headers: {
              'Content-Type': 'application/json; charset=utf-8'
            }
        }
        )
        .then((response) => {
            if (response.data) {
                console.log(response.data);
            }
        })

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)