Beginner Tip Do HTTP Request from JSON

Hi Guys,

i am rly new to NodeRed. I hope someone can help.

I used an API from NASA and get a json answer on my debugwindow.

msg.payload : Object

object

date: "1997-01-28"

explanation: "Many stars form in clusters. Two types of star clusters are visible in our Milky Way Galaxy: open clusters and globular clusters. Open clusters like M50, shown above, typically contain hundreds of..."

hdurl: "https://apod.nasa.gov/apod/image/9701/m50_kc_big.jpg"

media_type: "image"

service_version: "v1"

title: "Open Cluster M50↵Credit and Copyright:"

url: "https://apod.nasa.gov/apod/image/9701/m50_kc.jpg"

So my question is now: "How can i tell nodered that it should open the picture the upper url? "

What do you mean? Have node-red open the image in an image viewer on the same pc as node-red is running or on a client pc? Download the image to file? Present the image on a dashboard???

Hi Steve

NodeRed runs on a client PC. On Dashboard would be nice. I think i have to use a functionblock but i struggle with the code that i need to write in it.
Perfect would that when i deploy and run NR it give me the jsontext in the debugwindow and opens a new tab with the picture. Is it not possilble it would cool to see the picture via dashboard.

I want to see the Picture without copy the link from json in new tab. It should be done automaticly. I also dont want to download the pic.

ty

If you just wanna see the image you could....

http-request --> image node --> image viewer

see this - look at the Get image from internet demo. To import the built in example use CTRL+I --> examples.

copy the path to the image by using the copy path button & use that to get the image.

There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

Hi Steve
unfortunately i dont have access to the Image nodes....
My flow is now inject-> http request with api -> json -> debug
One way could be the json node. With this node i can use the single item in the json.

So i need a new http request but how do i bring my url from the first json into it?....

Why not? You can install it from manage pallete
image

put a change node after the JSON node and copy the JSON value to msg.url then feed that to a 2nd http request. The built in help tells you this...

image

Hi steve

sorry i dont get it. I can't install new nodes because i dont have install rights. Im using NR via institution.

So i have this flow now:
Timstamp-> httprequest-> json-> payload
-> change -> payload

i get this output form the upper payload
object
title: xxx
title2: yyy
tittle3:url

the url is title 3. What must i do in change node to get only title 3 and open this

Read the link i posted before

once you have the path to the URL, use a change node to set to copy the value from the path of that url into msg.url then pass that to another http request

ok i think i took a step forward. So i used a function node to seperate the url. When i deploy an run then NR tell me only the right URL.

So now i have to use the http request. Funktion go in and payload go out? But what do i need to set in the requust node?

the http request should take the url automaticly and open it

Nothing.

Just send the msg with msg.url set to the URL

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.