API call not working as expected


I a trying to call an api from the front end but i dont get the expected result.

This is frontend

 <div class="grid grid-container--fluid btn-toolbar">
  <div class="column-md-6" v-for="sensor in sensorData">
    <div class="column-md-6" v-if="getCurrentData(sensor.app_id_aqi)">
      <div v-for="data in currentData">

Javascript method

 getCurrentData(apiID) {
            console.log("apiid", apiID)

            axios.get("api/getCurrentData/"+apiID).then((response) => {
                this.currentData = response.data;
                console.log("currentData", this.currentData)

            }).catch(error => {

HTTP request node for API call

[{"id":"d8226eb44f302e20","type":"http in","z":"e3b2a296f968effa","name":"","url":"/api/getCurrentData/:apiID","method":"get","upload":false,"swaggerDoc":"","x":170,"y":700,"wires":[["4a88ebf475955c77","2af5585dec07c33b"]]},{"id":"2af5585dec07c33b","type":"http request","z":"e3b2a296f968effa","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://data.sensor.community/airrohr/v1/sensor/{apiID}/","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"credentials":{},"x":410,"y":680,"wires":[["644a880fdd5c82a6"]]},{"id":"644a880fdd5c82a6","type":"debug","z":"e3b2a296f968effa","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":570,"y":700,"wires":[]}]

When i do a normal get method like https://data.sensor.community/airrohr/v1/sensor/72267/ i get the response but when i am passing th apiid from the method, it doesnt work and i get below response


Can anyone help here please

From the built in help of the HTTP Requst node...

When configured within the node, the URL property can contain mustache-style tags. These allow the url to be constructed using values of the incoming message. For example, if the url is set to example.com/{{{topic}}}

Your URL is set to https://data.sensor.community/airrohr/v1/sensor/{apiID}/ << note the single { } curly brackets

1 Like

Hi @Steve-Mcl

I am passing the apiID which i get from the payload of the function node shown below

this is my http request node

still the response is same

it works!!!Thanks a ton

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