首页 > 解决方案 > Axios 帖子未在 AWS lambda 函数上调用

问题描述

我在使用 Lambda 函数时遇到了一些麻烦。

我正在尝试通过 lambda 函数通过 Axios 进行 API 调用。我已经在 Postman 中测试了这个电话,我确信它正在工作。

从 cloudwatch 日志看来,我根本没有调用该函数。我认为我在 AWS 上的设置有问题,但我想不出它可能是什么。

进口:

import axios from 'axios';

调用函数:

 public static async refreshToken(refreshToken: string): Promise<IToken> {
        
         let headers = {
                      "Content-Type": "application/x-www-form-urlencoded",
                      "Authorization": `Basic BASE_64_ENCODED_CODE`
                    };
        
        let url = "https://api.fitbit.com/oauth2/token?grant_type=refresh_token&refresh_token=REFRESH_TOKEN"
        
         let response = await axios.post(url, null, {
                      headers
                    });
        
         return {
                    accessToken: response.data.access_token,
                    expiry: Date.now() + response.data.expires_in,
                    refreshToken: response.data.refresh_token,
                };
        
    }

标签: node.jstypescriptamazon-web-servicesaws-lambdaaxios

解决方案


推荐阅读