我正在尝试使用"Amplifyjs"来处理AJAX请求,就像John Papa在他的Pluralsight课程中一样,但我遇到了身份验证方面的问题.
我正在使用表单身份验证.一切正常.
我的问题来自未经身份验证的请求.我找不到一种方法让"amplifyjs"回复错误函数http代码(401,403 ...)来区分失败的请求,因为它们未被验证因为没有遇到业务逻辑而失败的请求.
请求示例如下:
amplify.request.define("products", "ajax", {
url: "/api/Products",
datatype: "json",
type: "GET"
});
amplify.request({
resourceId: "products",
success: callbacks.success,
error: function (datos, status) {
//somecode
}
});
Run Code Online (Sandbox Code Playgroud)
谢谢.
我刚开始将 amplify 与 GraphQL 结合使用。我正在设置数据库模式并在运行放大推送后自动生成函数。
\n我想要实现但不知道如何实现的目标
\n当调用API生成的函数来获取用户时,
\nlet user = await API.graphql(graphqlOperation(getUser,{id:userId}))\nRun Code Online (Sandbox Code Playgroud)\n我正在获取一个用户对象,但是,它看起来像这样 - 即使我确信数据库中的数据设置正确。
\nbuttons: {nextToken: null} -- WANT THIS TO INCLUDE ACTUAL INFORMATION ABOUT BUTTONS CONNECTED TO THIS USER\ncreatedAt: "2020-09-02T23:41:12.278Z"\ncustomStyles: {id: "e3d1bbef-ec6f-4a6d-9b5d-e693e890d4e0", bgColor: "F9FF9F", bgBtnColor: "FFFFFF", bgBtnHoverColor: "000000", textColor: "000000", \xe2\x80\xa6}\ndefaultStyles: null\nemail: "nata@email.edu"\nfirstName: "Nata"\nid: "d683a6bb-383e-4cf1-943a-05b3da4e5cc3"\nlastName: "Vache"\nsocialNetwork: {nextToken: null} -- WANT THIS TO INCLUDE ACTUAL INFORMATION ABOUT SOCIAL NETWORKS CONNECTED TO THIS USER, THE …Run Code Online (Sandbox Code Playgroud) amazon-web-services amplifyjs graphql-js aws-amplify graphql-schema
我刚刚将"amplify.js"添加到我的ASP.NET MVC3项目中,并为此行获取了正则表达式语法错误:
key = key.replace( /[^-._0-9A-Za-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u37f-\u1fff\u200c-\u200d\u203f\u2040\u2070-\u218f]/g, "-" );
Run Code Online (Sandbox Code Playgroud)
有谁知道这个注册表有什么问题?
谢谢你的帮助
我使用 AWS 的 Amplify 创建了一个 GraphQL API。在架构中,我有一个评论模型,如下所示:
type Comment
@auth(rules: [{ allow: owner }, { allow: private, operations: [read] }, { allow: public, operations: [read] }])
@model
@key(name: "byAuthor", fields: ["authorID"])
@key(name: "byPost", fields: ["postID"]) {
content: String!
createdAt: AWSDateTime!
id: ID!
owner: String
postID: ID!
updatedAt: AWSDateTime!
}
Run Code Online (Sandbox Code Playgroud)
这为所有者提供了创建、读取、更新和删除的权限,并将未经身份验证/经过身份验证的非所有者用户限制为只读。这按预期工作;然而,所有者可以更新ownerField 的值,本质上是将评论归因于另一个用户......这是一个禁忌。为了防止这种情况,我尝试使用字段级权限(见下文);然而,这似乎并没有阻止更新。
...
owner: String @auth(rules: [{ allow: owner, operations: [ create ]}])
...
Run Code Online (Sandbox Code Playgroud)
我有什么遗漏的吗?非常感谢任何帮助——谢谢!
amazon-web-services amplifyjs graphql aws-amplify aws-amplify-sdk-js
我目前正在开发一个 React Native 项目,其中使用 AWS Amplify 作为我的后端 API。我尝试向 Amplify API 添加模拟以进行测试,但使用此命令时遇到错误:
amplify mock api
Run Code Online (Sandbox Code Playgroud)
导致此错误消息:
Edit your schema at
/***/***/***/***/amplify/backend/api/***/schema.graphql or place .graphql files in a directory at /***/***/***/***/amplify/backend/api/***/schema
Failed to start API Mocking. Running cleanup tasks.
Reason: Error: Parse error on resolvers/Query.syncCouriers.req.vtl:11:50
Parse error on line 12:
...tx.stash.authFilter.or ) #if( $fil
-----------------------^
Expecting 'ID', 'CONTENT', got '||'
Run Code Online (Sandbox Code Playgroud)
我不确定到底是什么导致了这个错误以及如何解决它。我已经检查了我的架构文件并确保其格式正确。我还尝试在指定目录中创建单独的 .graphql 文件,但错误仍然存在。
包.json:
{
"name": "ubereatsuser",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo …Run Code Online (Sandbox Code Playgroud) amplifyjs graphql react-native aws-amplify aws-amplify-sdk-js
我有一个mvc应用程序,我在TypeScript中编写客户端代码,以及使用几个众所周知的javascript库,包括knockout,amplifyjs和requirejs.我遇到了预期行为不会发生的情况.
export class OrganizationOverviewViewModel{
openedAssessments = ko.observableArray();
availableSurveys = ko.observableArray();
organizationAgentId = ko.observable();
organizationName = ko.observable();
selectedSurvey = ko.observable();
public addSurvey() {
if (this.selectedSurvey() === undefined) {
mh.MessageHub.showError("Please Select a Survey", "what");
}
else {
// we can do the post.
// get the selected survey
var surveyId = this.selectedSurvey();
// call the server to add the survey
amplify.request("addSurveyToOrganization", {
"surveyId": surveyId,
"organizationAgentId": this.organizationAgentId()
},
function (data) {
var context = ko.contextFor($('#mainContent')[0]).$data;
context.openedAssessments.push({ surveyId: data.SurveyId, SurveyName: data.SurveyName, NumberOfResponses: data.ResponseCount }); …Run Code Online (Sandbox Code Playgroud) 我刚开始在我的应用程序中使用 AWS Cognito,我按照说明安装了 Amplify 并创建了用户池和身份池并设置了所有内容。我创建了一个注册表单并在没有问题Aut.signUp()和确认电子邮件的情况下进行了注册。
但是当我尝试登录时,我输入了我的凭据并得到 NotAuthorizedException,用户名或密码不正确。
我是这样登录的:
Auth.signIn(user.Username, user.Password)
.then((res) => {
AsyncStorage.setItem('token', JSON.stringify(user))
.then(res =>{
console.log('saved')
})
.catch(err=>{
console.log(err)
})
Run Code Online (Sandbox Code Playgroud)
无论我在输入字段中输入什么,我都会收到此错误。我刚开始使用 Amazon AWS,实在想不出问题
amplifyjs ×7
aws-amplify ×4
graphql ×2
react-native ×2
ajax ×1
graphql-js ×1
javascript ×1
knockout.js ×1
regex ×1
this ×1
typescript ×1