首页 > 解决方案 > 如何为请求重试添加自定义标头?

问题描述

我的电话是这样的,

const { get, post } = require('requestretry');
const { promisify } = require('util');
const [getAsync, postAsync] = [get, post].map(promisify);

    const res = await postAsync({
        url: "some url",
        json: messageObj, // request body
        maxAttempts: 5,
        retryDelay: 1000
    });

请问在哪里可以添加自定义标题? https://www.npmjs.com/package/requestretry?activeTab=readme

标签: node.jsrequest

解决方案


const res = await postAsync({
    url: "some url",
    headers: {...},
    json: messageObj, // request body
    maxAttempts: 5,
    retryDelay: 1000
});

推荐阅读