I have a VM running kairosDB on laptop A,the VM has two IPs: 192.168.119.132 : to access it from laptop A. 192.168.1.151 : to access from laptop B.
From both laptops i can access the web app without any issue from < IP >:8080.
Laptop A : If i execute the POST/GET request shown in the code, everything work perfectly. (using IP 192.168.119.132)
Laptop B : Only GET request works ! the post request return code 200, but no point is added to the db when using POST.
Any help to make the POST request work please?
const fetch = require("node-fetch");
let query = {
"metrics": [{
"tags": {},
"name": "matric1",
"group_by": [{
"name": "tag",
"tags": [
"car_type",
"host",
"mode_type"
]
}]
}],
"plugins": [],
"cache_time": 0,
"start_relative": {
"value": "20",
"unit": "seconds"
}
};
let dataPoint = [{
"name": "matric1",
"type": "long",
"value": 88,
"timestamp": Math.floor(Date.now()),
"tags": {
"car_type": "TEST",
"host": "TEST",
"mode_type": "TEST"
}
}];
function fetchData(query) {
fetch('http://192.168.1.151:8080/api/v1/datapoints/query?query=' + JSON.stringify(query), {
method: 'GET'
})
.then(res => res.json()) // expecting a json response
.then(json => console.log(json));
}
function addDataPoint(dataPoint) {
fetch('http://192.168.1.151:8080/api/v1/datapoints', {
method: 'POST',
body: JSON.stringify(dataPoint),
headers: {
'Content-Type': 'application/json'
}
})
.then(res => console.log("successfully added !"))
}
addDataPoint(dataPoint);
fetchData(query);