javascript – Homey SDK using "fetch" for http API request – Stack Overflow
I want to write an App for Homey that sends data to my Server via http request.
async onInit() {
try{
this.log('start)
const fetch = require('node-fetch');
fetch("http://example.com/movies.json")
.then((response) => response.json())
.then((data) => this.log(data));
this.log('end)
}catch(error){
this.log(error)
}
But i only get the start and end log in the console and nothing else, not even an error.
What is wrong. Is there any example how to get data from homey to my cloud?
I tried to import “fetch” differently but with no success.
const fetch = require(‘node-fetch’)
const fetch = require(‘fetch’)
import fetch from ‘node-fetch’
Thank you
Read more here: Source link
