Can someone please guide me how to get the data from a text file in react js? Usually the data extracted from the API is in JSON format but this time I want to render the data that is in .txt file format.
1 Answer
for you to display a doc text like o told me using simple html and css you can use this exemple:
$(document).ready(function() {
$(".word").fancybox({
'width': 600, // or whatever
'height': 320,
'type': 'iframe'
});
}); // ready
<a class="word" href="//docs.google.com/gview?url=http://www.picssel.com/demos/downloads/Fancybox.doc&embedded=true">Open a Word document in Fancybox</a>
9 Comments
xiang
I am getting this error now. Access to fetch at 'example.com/sample.txt' from origin 'localhost:3000' has been blocked by CORS policy
xiang
but i do get JSON data with it when converting to JSON where there is 'text'.
NoobDEV-GBL
you really have to work white txt? why not json?
xiang
Yes, I have to work with text file as the data available to me is in text format. Is there any possibility to do it successfully?
xiang
so the error has now gone with the help of { mode: "no-cors" } but i am getting "undefined".
|