CORS on a Node.js server – send data

19/04/2016

תגיות: , , , ,
2 תגובות

In last post I showed you to open your REST service for everyone to collect data out of it. I n this post I will show you how easy it is also to allow external origin to send data to your service. It is as simple as the last post with just one line.

The scenario for this this requirement is fairly simple, you have a REST service which externalize CRUD operations for some data. e.g. a book collection where you can add new books, update, remove, etc.

If we return to our middleware function, we need to add just one line of code like this:

This will allow us now to add new books to our books collection via our REST service without trouble.

Now the REST service is open for public.

הוסף תגובה
facebook linkedin twitter email

Leave a Reply

Your email address will not be published. Required fields are marked *

2 תגובות

  1. dor cohen20/08/2016 ב 06:19

    I have been absent for some time, but now I remember why I used to love this blog. Thank you, I will try and check back more frequently. How frequently you update your web site?

    Reply
    1. Shahar Eldad
      Shahar Eldad02/11/2016 ב 11:42

      Every now and then. Not regularly as I wish

      Reply