【发布时间】:2021-05-05 19:45:01
【问题描述】:
我是 AWS API 网关和 Lambda 的新手。我正在尝试获得基本的“来自 Lambda 的你好!”功能正常工作。
我可以成功登录如下:
const user = await Auth.signIn(email, password);
我得到了一个正确的令牌,因为我在 AWS API 控制台上对其进行了测试并得到了响应
//token works as tested on AWS Console (API Tester)
const token = user2.signInUserSession.idToken.jwtToken
我假设请求信息是正确的,因为令牌是正确的:
const requestInfo = {
headers: {
Authorization: token
}
}
我认为错误就在这里,因为每当我尝试对“数据”做任何事情时,我都没有得到回应
const data = await API.get('API_NAME','/hello',requestInfo)
console.log('This is the Data: ',{ data } )
我在 try/catch Xcode 中遇到的错误是:
'API API_NAME does not exist'
有什么建议吗?
我在运行 Amplify Push 时遇到错误:
Packaging lambda failed function failed with the error
Command failed with exit code 1: npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: APP_NAME@1.0.1
npm ERR! Found: react@16.8.6
npm ERR! node_modules/react
npm ERR! react@"16.8.6" from the root project
npm ERR! peer react@"^16.7.0" from @aws-amplify/ui-react@0.2.36
npm ERR! node_modules/@aws-amplify/ui-react
npm ERR! @aws-amplify/ui-react@"^0.2.35" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.14.0" from react-dom@16.14.0
npm ERR! node_modules/react-dom
npm ERR! peer react-dom@"^16.7.0" from @aws-amplify/ui-react@0.2.36
npm ERR! node_modules/@aws-amplify/ui-react
npm ERR! @aws-amplify/ui-react@"^0.2.35" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/name/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/name/.npm/_logs/2021-02-02T09_36_01_091Z-debug.log
An error occurred during the push operation: Packaging lambda failed function failed with the error
Command failed with exit code 1: npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: APP_NAME@1.0.1
npm ERR! Found: react@16.8.6
npm ERR! node_modules/react
npm ERR! react@"16.8.6" from the root project
npm ERR! peer react@"^16.7.0" from @aws-amplify/ui-react@0.2.36
npm ERR! node_modules/@aws-amplify/ui-react
npm ERR! @aws-amplify/ui-react@"^0.2.35" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.14.0" from react-dom@16.14.0
npm ERR! node_modules/react-dom
npm ERR! peer react-dom@"^16.7.0" from @aws-amplify/ui-react@0.2.36
npm ERR! node_modules/@aws-amplify/ui-react
npm ERR! @aws-amplify/ui-react@"^0.2.35" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/name/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/name/.npm/_logs/2021-02-02T09_36_01_091Z-debug.log
【问题讨论】:
标签: react-native aws-lambda react-native-android aws-api-gateway react-native-ios