ene*_*fuu 6 react-native aws-sdk-js
在 React Native 中使用适用于 JavaScript v3 的 AWS 开发工具包中的 SNS 服务
当我尝试创建端点(或通过 AWS 执行任何命令)时,出现此错误URL.hostname is not implemented
region
在创建客户端时从参数中删除。Region is missing
然后它在同一个地方出错。但值得注意的是,如果我只是asdf123
为区域传递无意义的 (),它会产生相同的 URL.hostname 错误import { CognitoIdentityClient } from "@aws-sdk/client-cognito-identity";
import { fromCognitoIdentityPool } from "@aws-sdk/credential-provider-cognito-identity";
import { SNSClient, CreatePlatformEndpointCommand } from "@aws-sdk/client-sns";
const region = 'us-west-2'
const sns = new SNSClient({
region: region,
credentials: fromCognitoIdentityPool({
client: new CognitoIdentityClient({ region }),
identityPoolId: identityPoolId,
}) /// doesn't matter whether I pass credentials or not, same result
});
const params = {
PlatformApplicationArn: platformApplicationArn,
Token: token
}
const command = new CreatePlatformEndpointCommand(params);
const res = await sns.send(command)
.catch((err) => {
console.log(err) //// this is the "[Error: not implemented]"
throw err
})
Run Code Online (Sandbox Code Playgroud)
这意味着我应该在此错误中包含更多数据,但此错误中唯一的内容就是消息。https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-sns/index.html#troubleshooting
似乎这甚至不是 AWS 错误...但我不知道如何进一步排除故障。
任何有关如何确定其来源的建议将非常感激。谢谢大家
ene*_*fuu 23
发现一些帖子建议这样做以解决类似的错误:react-native-url-polyfill
添加后,我开始收到此错误:
[Error: crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported]
为了解决这个问题我添加了react-native-get-random-values
...并且它有效。我不确定我理解为什么,或者根本原因是什么,这似乎是一个有点混乱的解决方法。但它确实有效。
import 'react-native-url-polyfill/auto';
import 'react-native-get-random-values';
import { v4 as uuidv4 } from 'uuid';
//at the top of the file where I'm handling AWS SNS
Run Code Online (Sandbox Code Playgroud)
如果有人可以阐明这里发生的事情,毫无疑问有更好的方法。
归档时间: |
|
查看次数: |
6345 次 |
最近记录: |