Cristi Istrate
Cristi Istrate

Reputation: 23

JS await fetch => [object Response]

I have this issue: An API (Blynk.cc) have 2 output posibile: TRUE or FALSE (simple text, no JSON) When accesing https://ip:port/APIKey/isHardwareConnected I get TRUE of FALSE When I try to get this result with: response = await fetch(url) the response printed is [object Response] not TRUE or FALSE. Can you help me ? Thank you

Upvotes: 0

Views: 264

Answers (1)

Ankit dagar
Ankit dagar

Reputation: 127

i could help better if their was a example ,but you can try this. you need to run .text() function on response.

 fetch('http://example.com/movies.json')
  .then(response => response.text())
  .then(data => console.log(data));

your answer

const energielive = 'http://cristianistrate.go.ro:8080/oF3rMGDvjOrWLppZfgS9pqgulWyforSn/isHardwareConnected';
      let response = await fetch(energielive).then(response => response.text());
      console.log(response);

Upvotes: 1

Related Questions