How do I read an external text file? I have tried wix-fetch but all examples reference to local files.
Can someone share a quick example reading .txt file stored in a public HTML location?
Thanks!!
import {fetch} from "wix-fetch";
fetch("https://www.w3.org/TR/PNG/iso_8859-1.txt")
.then(r => r.text())
.then(text => console.log(text));
Thank you!!
This works well for https://, but fails to fetch from http://
The code:
import {fetch} from “wix-fetch” ;
fetch( URL of an HTTP .txt file here )
.then(r => r.text())
.then(text => console.log(text));
results in:
Failed to fetch
I appreciate any other ideas!
Hi,
Tried it and it worked perfectly. Maybe your URL starts with http and not https?