是否可以 call/await 没有所有参数的异步函数?

Is it possible to call/await an async function without all the parameters?

我正在尝试 post 一个 'x-www-form-urlencoded' 数据到 Twitter API。有四个参数可以填写,sender_screen_name, status, attachment_url, media_ids.

示例代码:

async function postTweet(sender_screen_name, status, attachment_url, media_ids) {

const sendTwt = {
    url: 'https://api.twitter.com/1.1/statuses/update.json',
    oauth: oAuthConfig,
    form: {
    status: status,
    attachment_url: attachment_url,
    media_ids: media_ids
    }
};
console.log(`[${time}] [CONSOLE] Tweeted user @${sender_screen_name}'s message`);
await post(sendTwt);
}

现在关键是,如果我这样称呼它:

await postTweet(senderScreenName, encodeMsg);

成功post,只需填写sender_screen namestatus参数即可。现在,在另一个调用中,我想填充第四个参数 (media_ids) 并将第三个参数 (attachment_url) 留空或不包含任何内容。

我试着用这样的 null 来调用它:

await postTweet(senderScreenName, encodeMsg, null, encodeImg);

但是,现在 returns 出现 400 Bad Request 错误。我可以通过哪些方式进行此操作?

await postTweet(senderScreenName, encodeMsg); 等同于 await postTweet(senderScreenName, encodeMsg, undefined, undefined);.

所以,尝试 await postTweet(senderScreenName, encodeMsg, undefined, encodeImg);