I made the simplest server in NodeJS, which stocks strings in a database when requested "/add"
and sends to my front (ReactJS) all of those strings "/getall"
. I display them using the map
function. Everything works as expected. But, my information is displayed only on Desktop browser, not on mobile browser (Safari or Chrome).
Web
Mobile
async fetchFromDatabase(){
let url = "http://localhost:8080/getall"
let c = 0
await fetch(url).then((response) => {
response.json().then((data) => {
let values = []
for (let i in data) {
values.push(data[i].post)
c++;
}
this.setState({
posts: values
})
});
});
}
To fill in my array, I do this:
let allPosts = this.state.posts.map(item => (
<div key={item} className="center-div">
<p className="box">
{item}
</p>
</div>
))
To render the information, I do this:
<div>
{allQuestions}
</div>
Fetch is definitely not working for mobile. Has anyone experienced something like this?