Vue.js resource, method "post" and "delete" do not work


look this little project (In the event of an error, allow access origin … use the chrome extension “allow -control-allow-origin”)
So, the method “get” work fine and the data are published ,but post (for addFilm) and delete (for cancellaFim) do not work… please help me, I am becoming crazy… thanks


Your server blocks the request because of CORS.

Access to XMLHttpRequest at ‘’ from origin ‘’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

If you want to be able to make requests to your server, you need to adjust the CORS config.


this is not my problem. I also explained … on codepen I can not upload files (film.json) and I had to upload it to my host. If you want to download the project folder here!io8ghITa!SMxQAxkTNJ-3EO5GNI5l-A. My problem are the method post and delete…


Yes. Because your server blocks the requests because of CORS. Your issue is exactly as I have pointed out.


But no… if you use the extension the date the data is uploaded. download the project that mega and test it locally will see that no error of access allow origin. IT IS NOT MY PROBLEM! uff…


CORS error occurs because I loaded the movie.json file on my host … But my project is locally I’m not interested in resolving that error (which I still solved with the chrome extension)


I see. That wasn’t clear in your post. Your issue is because you aren’t using an API to update your data. You can’t just post/delete to a json file. You need to use an API endpoint on your server. That endpoint then uses a controller to apply the necessary changes to your database (or to update the file, but that’s a very inefficient and potentially messy way of storing data - though MongoDB uses a similar approach but has an entire API).


but with vue resource it is possible to insert or delete records in an array and without API …


You will need to elaborate because this definitely isn’t possible from the client side. The server handles the request and needs to be instructed on how to handle it.