当我尝试使用restangular进行put或者删除时,我有这个错误的帖子和getList()完美地工作, 当我要编辑mi对象时,我会创建一个像这样的对象
edited = Restangular.copy(danger);
危险是我的模板中的模式对象我只是从表中抓取对象,对象很好。 然后在我的功能中,我只是尝试做
edited.put();
,错误是OPTIONS http://dangers/1/ net :: ERR_NAME_NOT_RESOLVED
像restangular没有生成网址,帖子网址是http://localhost:8000/dangers/
我在开发环境中使用gulp代理来捕获api请求
gulp.task('server', ['build'], function() {
gulp.src('./build')
.pipe($.webserver({
port: 8080,
host: 'localhost',
fallback: 'index.html',
livereload: {
enable: true,
port: 8181
},
open: true,
// django app
proxies: [{
source: '/api',
target: 'http://localhost:8000/api'
}]
}));
});
答案 0 :(得分:0)
这是我的错误django restframework需要在每个url中使用尾随斜杠,解决方案是在restangular的配置中添加
RestangularProvider.setRequestSuffix(' /&#39);