everything is after each other, how to put them under eachother ? in the website code is put like this : style=“word-wrap: break-word; white-space: pre-wrap;” i want them to be under each other like this 5:789
I am not sure what you are asking. I would need to see more of your code to understand what you are currently doing. Does state now contain a property named “contents” which is an array of the strings you wanted?
thank you for your code, its working but the numbers im getting from that site are like this now 5:8995:8995:8995:899 but i want them to be under each other like this 5:899
and could you possibly explain why my code was not working properly ?
Again, unless you can show the code which creates the html for how you are displaying the numbers, I can not help you. I need to see the html structure and how you are referencing the data in this.state.contents.
The text() method returns a promise, so you were not going to get any workable data until then 2nd then method.
What does the code for the nappula component look like? Have you studied React before or are you just trying to hack code you found somewhere else? When I asked for you to post the code which renders the html structure, you should already know I meant the code which displays this.state.contents.
I strongly advise you to look at our React curriculum to help you get better acquainted with React.
Sorry about that. this.state.contents is an array, so unless you iterate through it to display it with some other html structure, it is just going to display like you mention (all in the same line). If you want to display each number on separate lines, think about the html structure needed to do that. You could use an unordered list or just div elements. You can use the map to create the necessary html structure for this, but I will first let you attempt to write the code yourself instead of just showing you how to do it. We have a great React course which shows you how to do such things.
This just splits the string data you received from the fetch call by end of line character. The actual data in the contents array, are just numbers. There is no styling or html associated with each number from what you have explained to me.