gpt4 book ai didi

javascript - Ext js Rest代理使用请求URL而不是代理中定义的REST API URL

转载 作者:行者123 更新时间:2023-12-03 04:19:53 24 4
gpt4 key购买 nike

我正在使用 Ext js Rest 代理来执行 Rest API 的 CRUD 选项。在存储和服务器之间同步数据时,代理使用客户端请求 url 而不是代理中定义的其余 URL,同时从存储中删除数据。

模型类:

Ext.define('RestroApp.model.Restro', {
extend:'Ext.data.Model',
alias:'model.restro',
idProperty:'restroId',
identifier: 'sequential',
fields:[
{name:'restroName', type:'string'},
{name:'address', type:'string'},
{name:'restroId', type:'string'},
{name:'latitute', type:'int'},
{name:'longitute', type:'int'},
{name:'isVeg', type:'boolean'}
]
});

商店类别:

Ext.define('RestroApp.store.RestroStore', {
extend:'Ext.data.Store',
storeId:'restostore',
alias:'store.restrostore',
requires:['RestroApp.model.Restro'],
model:'RestroApp.model.Restro',
proxy:{
type:'rest',
api:{
read:'http://localhost:12080/restro/list',
create: 'http://localhost:12080/restro/add',
update:'http://localhost:12080/restro/update',
destory:'http://localhost:12080/restro/delete'
},
reader:{
type:'json'
},
writer:{
type:'json'
}
},
autoLoad:true
});

我正在 http://localhost:8007 上运行我的 ext js而休息 api 上 http://localhost:12080

例如。 View Controller

Ext.define('RestroApp.view.main.RestroListController', {
extend:'Ext.app.ViewController',
alias:'controller.restrocontroller',
requires:['RestroApp.model.Restro'],
refreshData: function (){
var store=Ext.getStore('restostore');
store.removeAt(0);
store.sync();
}
});

就像从存储中删除数据时会出现错误DELETE localhost:8007/3?_dc=1494918882624 405(此 URL 不支持 Http 方法 DELETE)配置的 URL 为 localhost:12080/retro/delete

最佳答案

您的 destroy api 属性有一个拼写错误 - “destory”。

关于javascript - Ext js Rest代理使用请求URL而不是代理中定义的REST API URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43994935/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com