Search code examples
javascriptangularjsdjangoapirestangular

restangular remove and put error net::ERR_NAME_NOT_RESOLVED


i have this error when i try to do a put or a remove with restangular the post and the getList() works perfectly, when i'm going to edit mi object i create a object like this

edited = Restangular.copy(danger);

danger is my modelobject from my template in a table i just grab the object from the table, the object is fine. then in my function i just try to do

edited.put();

and the error is OPTIONS http://dangers/1/ net::ERR_NAME_NOT_RESOLVED

like restangular is not generating the url, the post url is http://localhost:8000/dangers/

i'm using gulp with a proxy in the dev enviroment to capture the api requests

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'
        }]
    }));
});

Solution

  • This was my error django restframework needs the trailing slash in every url the solution was to add in the config of restangular

    RestangularProvider.setRequestSuffix('/');