0

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.

2

1 Answer 1

1

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>

Sign up to request clarification or add additional context in comments.

9 Comments

I am getting this error now. Access to fetch at 'example.com/sample.txt' from origin 'localhost:3000' has been blocked by CORS policy
but i do get JSON data with it when converting to JSON where there is 'text'.
you really have to work white txt? why not json?
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?
so the error has now gone with the help of { mode: "no-cors" } but i am getting "undefined".
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.