Noob: Getting data from the server to the client


I got a form where the user sends in a image link.
The link is sent to a method that sends it to a http api and then get a result back from the api with some image information. I want to display that result on client side.

How would you do that? Should I use mongo and subscribe/publish?

  1. Are you trying to implement something like an open graph feature?

There will be many ways to implement what you are trying to achieve, and this is my humble opinion:

If the image link is your internal site’s link, you can just load the image on the client. But if the image is on an external site, depending on http protocol it can cause a mixed contents warning when you load this directly on a browser and if your site is using ssl.

So, if you can get the image binary on your server-side and save it in the mongo or another web-server like nginx, you can serve it from there. However, to do this, you need to do crawling in advance, or you can add a check logic and if the link already has collection in the DB that contains your internally saved image info, then you can serve it.

  1. or if you are asking about how to get the response, it depends on the pattern you want. Of course, you can use reactivity using pub-sub, then the client will load the newly added collection. Or if you implement synchronized method, you can display the result in the api callback.