简体   繁体   中英

Angular $resource.save to json file does not work

hope to get some help ;)

the following code does not make .json file with new data info. I suspect it is a stupid mistake I have permissions for the data/artist folder

 'use strict'; musicApp.factory('artistData', function($resource) { var resource = $resource('/data/artist/:id', { id: '@id' }); return { getArtist: function(id) { return resource.get({id: id}); }, saveArtist: function(artist) { if (!artist.id) { resource.query().$promise.then(function(data) { artist.id = data.length + 1; resource.save(artist); }); } else { resource.save(artist); } }, getAllArtists: function() { return resource.query(); } } }) 

The form is $valid but I have in Console: Failed to load resource: the server responded with a status of 501 (Not Implemented)

I needed to add this in web-server.js

  if (req.method === 'POST') { if (self.attemptingToAccessOutsideLocalAppPath(parts)) { return self.sendForbidden_(req, res, path); } return self.writeFile_(req, res, path); } 

Now works fine and adds new json files in data/artist

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM