All of the functions below either error out or return a blank object from the jsonplaceholder testing endpoint. Tested the URL in Postman and all results come back fine and it also works in HTTP.
usually the error itself can have better hints than a video, maybe share the error that you get as text.
And of course if this is in a js action you need to actually rerurn something from it. Think about it as the body of an async function, you want to return something, not only invoke other functions.
it is indeed in one of the function that you invoke but the action itself is not returning anything.
This is very easy once you get it. Forget about the actual data fetching and return a sample array, then add the fetching.
The output JSON is:
{
“posts”: [
{
“id”: 1,
“title”: “His mother had always taught him”,
“body”: “His mother had always taught him not to ever think of himself as better than others. He’d tried to live by this motto. He never looked down on those who were less fortunate or who had less money than him. But the stupidity of the group of people he was talking to made him change his mind.”,
“userId”: 9,
“tags”: [
“history”,
“american”,
“crime”
],
“reactions”: 2
},
{…},
{…}
// 30 items
],
“total”: 150,
“skip”: 0,
“limit”: 30
}
The main() function lacks a return statement. You need return data after getting it from fetchPosts.
The outer code lacks a return statement. You need to insert the word return before main(), e.g. `return main()
Take care of those and you’re probably good to go. Let us know if you have ongoing issues!
Also, @dorilama is the single most expert person on here who is not part of the weweb team. He is also the nicest in helping people with their hard problems. He is not paid to help on this community (nor am I). Let’s all be at least half as nice to him so we can keep this wheel of learning turning for all of us!
To be perfectly honest, I always prefer to side on the nice or neutral side, but I did see a couple of @dorilama responses in other threads and his tone there and in this thread made me feel small and somewhat “stupid”, with an overall “elitist” demeanor, and his responses certainly were not decorated with any kind of traditional social decorum, so my initial reaction was not the most positive to say the least.
Sure no one has to be nice or polite or provide any more info than necessary in contexts like this forum, but then one shouldn’t expect unequivocal niceties in return either .
But again, thank you both for taking the time to help me work through this very basic and fundamental concept, and yes I complete agree that one should have an understanding of what is happening in the development process instead of just seeking copy/paste responses.