# Node red with microservices

**URL:** <https://discourse.nodered.org/t/node-red-with-microservices/9763>\
**Category:** General\
**Created:** [4 April 2019 10:09 UTC](https://discourse.nodered.org/t/node-red-with-microservices/9763 "2019-04-04T10:09:01Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arth](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@Arth](https://discourse.nodered.org/u/Arth)\
**Post date:** [4 April 2019 10:09 UTC](https://discourse.nodered.org/t/node-red-with-microservices/9763/1 "2019-04-04T10:09:01Z")

</div>

Hello,  
I would like to do following example:  
I would like to have my own microservice - for example - /weater?location=? (and how can I do that "?" would be changed to wanted location in node red?) - then in other node - there should be http request, which should send request to some working API with  
location from the url (location=?) - this API should send back JSON with information - I want these information send back to client who used my microservice.

1. Is my flow ok? Should it work?  
2.I have microservice - /weater?location=? - ? should be always replaced with a location in that url. How can I do that?
2. In http request I have:  
[https://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b6907d289e10d714a6e88b30761fae22](https://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b6907d289e10d714a6e88b30761fae22)  
Again, I need to replace "q=London" with something like "q=?" and "?" should be replaced with location in previous url
3. If request is successfuly sent, client should receive answer (json) in http response, am I right?

![V%C3%BDst%C5%99i%C5%BEek](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/7904b87299f8289057611cacf5351d4c684e9ba3.png)

Thank you for you help

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [4 April 2019 10:13 UTC](https://discourse.nodered.org/t/node-red-with-microservices/9763/2 "2019-04-04T10:13:56Z")

</div>

If you start with a http-in you need to end your flow with an http-out

You will also need to have some logic & reformating between your http-in and your http request nodes.

Try looking at the function node.  
Each node in the info panel on the right hand side should explain what part of the message object key bits of information should go in.

There are also examples of using http nodes in the cookbook at [cookbook.nodered.org](http://cookbook.nodered.org)

---

<div class="post-metadata">

**Author:** ![Arth](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@Arth](https://discourse.nodered.org/u/Arth)\
**Post date:** [4 April 2019 10:50 UTC](https://discourse.nodered.org/t/node-red-with-microservices/9763/3 "2019-04-04T10:50:44Z")

</div>

Thank you for your reply.  
I progressed a little bit:  
First picture: Flow  
So when I go to localhost:1880/weater/London - then I get JSON {"q": "London"} in msg.req.params;  
Second picture: My function  
Just setting msg.payload with msq.req.parameters (because I thought msg.payload could be used for parameters in my final url)  
Third picture:  
Thre is option to use msg.payload as parameters - Does not work for me. I deleted from my api: q=London and tried to check "use msg.payload as parameters" - but it does not work.  
 ![V%C3%BDst%C5%99i%C5%BEek](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/7a39537a79df4dc6a67123ec4577be15e7aa4c68.png) ![V%C3%BDst%C5%99i%C5%BEek2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e32ec15e5e49e569d9e310521585d2d317ac1f67.png) !

So, how can I set q=Location from my msg.payload to my final api URL?

Thanks

---

<div class="post-metadata">

**Author:** ![Arth](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@Arth](https://discourse.nodered.org/u/Arth)\
**Post date:** [4 April 2019 10:51 UTC](https://discourse.nodered.org/t/node-red-with-microservices/9763/4 "2019-04-04T10:51:20Z")

</div>

Third picture:

 ![V%C3%BDst%C5%99i%C5%BEek3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/644114c3a6c17554e1d7cd48a33175f01bc08cee.png)

---

<div class="post-metadata">

**Author:** ![Arth](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@Arth](https://discourse.nodered.org/u/Arth)\
**Post date:** [4 April 2019 11:36 UTC](https://discourse.nodered.org/t/node-red-with-microservices/9763/5 "2019-04-04T11:36:17Z")

</div>

Ok, i figured it out. The problem was that I wrote localhost:1880/London - but api needs /London,uk - so it works as expected.

But I tried out to use google places (I downloaded it to node-red) and I have again very similiar problem with it...  
So in google-places node, there is NOT option to put msg.payload as parameters. How can I insert parameters from msg.payload to google-places node?  
Thank you again

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [4 April 2019 12:04 UTC](https://discourse.nodered.org/t/node-red-with-microservices/9763/6 "2019-04-04T12:04:35Z")

</div>

It’s useful if you include the full name of the node that you have installed.  
Assuming it is [https://flows.nodered.org/node/node-red-node-google](https://flows.nodered.org/node/node-red-node-google)  
The ReadMe includes full details of where in the msg object you need to include the data

---

<div class="post-metadata">

**Author:** ![Arth](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@Arth](https://discourse.nodered.org/u/Arth)\
**Post date:** [4 April 2019 13:15 UTC](https://discourse.nodered.org/t/node-red-with-microservices/9763/7 "2019-04-04T13:15:04Z")

</div>

Yes, when I write for example msg.location.lat (for example) in the function before google-places node - it says - lat is undefined. I also tried to return new msg object with location, lat, lon, radius, keyword etc in that function, but then it writes - no response object... and in google place node you can write parameters directly, but thats something I dont want to do...

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [4 April 2019 13:22 UTC](https://discourse.nodered.org/t/node-red-with-microservices/9763/8 "2019-04-04T13:22:00Z")

</div>

The read the logging events section on the function docs and use it to check what you are actually doing inside your function node

[https://nodered.org/docs/writing-functions#logging-events](https://nodered.org/docs/writing-functions#logging-events)

Alternatively if you think it is a bug, as it is a contrib node follow the link from the nodes page in [flows.nodered.org](http://flows.nodered.org) to the github page of the node where you can open an issue with the nodes author

---

<div class="post-metadata">

**Author:** ![Arth](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@Arth](https://discourse.nodered.org/u/Arth)\
**Post date:** [4 April 2019 13:40 UTC](https://discourse.nodered.org/t/node-red-with-microservices/9763/9 "2019-04-04T13:40:09Z")

</div>

I do not think, It is a bug - I would say problem is on my side.

I found out that I am getting JSON data back from google api - so i can read it in debugger, but http response node writes "no response object"... Any idea what might be wrong?  
Google place node is attached to debugger (works fine) and to http response node - does not work fine...

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [4 April 2019 13:54 UTC](https://discourse.nodered.org/t/node-red-with-microservices/9763/10 "2019-04-04T13:54:31Z")

</div>

Are you making sure that you pass the message received in the http request node on to the http response, and not removing response data (`msg.res`) in that message?

---

<div class="post-metadata">

**Author:** ![Arth](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@Arth](https://discourse.nodered.org/u/Arth)\
**Post date:** [4 April 2019 14:06 UTC](https://discourse.nodered.org/t/node-red-with-microservices/9763/11 "2019-04-04T14:06:42Z")

</div>

Yes, thank you!! I was creating a new msg object in the function and I did not specify this variable!

Thank you, it works fine now 🙂

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [4 April 2019 14:09 UTC](https://discourse.nodered.org/t/node-red-with-microservices/9763/12 "2019-04-04T14:09:31Z")

</div>

Glad it is working. In function nodes it is generally best to modify the existing message and pass it on rather than make a new one, unless there are special requirements that force that.
