SendGrid客户端打字稿错误:HttpMethod

我有:

import sendgridClient from '@sendgrid/client'
sendgridClient.setApiKey(process.env.SENDGRID_API_KEY);

const sendgridRequest = {
        method: 'PUT',
        url: '/v3/marketing/contacts',
        body: {
            list_ids: [myId],
            contacts: [
                {
                    email: req.body.email,
                    custom_fields: {
                        [myFieldId]: 'in_free_trial'
                    }
                }
            ]
        }
    };


await sendgridClient.request(sendgridRequest);

但是我的 TypeScript 语言服务器给了我一个错误sendgridRequest

Argument of type '{ method: string; url: string; body: { list_ids: string[]; contacts: { email: any; custom_fields: { e5_T: string; }; }[]; }; }' is not assignable to parameter of type 'ClientRequest'.
  Types of property 'method' are incompatible.
    Type 'string' is not assignable to type 'HttpMethod'.

有没有办法解决这个问题?

以上是SendGrid客户端打字稿错误:HttpMethod的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>