« first day (2881 days earlier)      last day (2073 days later) » 

1:02 PM
Look at this console result for my array
Also I tried quotations[0] but it gives underfined
 
@AbhishekBurkule Can you please show your code? I suspect you r new to javascript and stuck with its asynchronosity
 
Sure
var quotations = [];
    FB.api("/"+ albumID +"/photos?fields=images&limit=100&count&name",doSomething);
    function doSomething(response){

      response.data.forEach(photo => {
        photo.picture_full = photo.images[0].source; //[0] is the largest image
        delete photo.images; //Don't need the rest, only one
      });
      if (response.paging.hasOwnProperty('next')){
          FB.api(response.paging.next, doSomething);
      }
      quotations.push(...response.data);
    }
    console.log(quotations);
 
4385
Q: How do I return the response from an asynchronous call?

Felix KlingI have a function foo which makes an Ajax request. How can I return the response from foo? I tried returning the value from the success callback as well as assigning the response to a local variable inside the function and returning that one, but none of those ways actually return the response....

 
...response.data has object in that image and I am pushing it in quotations but now I am unable to get that back
 
read the question I just linked.
 
1:15 PM
console.log() will run before doSomething()
 
Okay but then How do I access entire pushed data outside the function after its done its work
 
6 mins ago, by Ben Fortune
4385
Q: How do I return the response from an asynchronous call?

Felix KlingI have a function foo which makes an Ajax request. How can I return the response from foo? I tried returning the value from the success callback as well as assigning the response to a local variable inside the function and returning that one, but none of those ways actually return the response....

 
@AbhishekBurkule async means the work isn't necessarily done when the call is finished. you use callbacks and promises to add a hook so that when it is done, you can deal with it then
 
Okay but I am bit confused in that how can I achieve it using my code ?
 
By applying the things that you learned to your own code.
 
1:30 PM
try to get the concept first
You say, "Do this, and let me know when you're finished by calling this method.."
that's it, that's the bulk of it
When the call is done, the work isn't done, just the call..
you only started the async job
libraries which provide async functions give you ways to provide functions when called
if you didn't, you wouldn't know when the work is done
nor would you have the results of that call
now, take what you learned and apply it here -- suppose I have function A which takes a really long time to run:
function A() {
    // LOTS OF WORK
}
How would you adapt this to be called asynchronously?
 
Okay I am getting it slightly now
 
function A(func) {
    setTimeout(function() {
        // LOTS OF WORK
        func();
    }, 0);
}
If I call A, it returns immediately after this call
but the work is getting done asynchronously
when it is done, it calls func(), right?
so the function you pass to it gets called when the work is done
If you didn't know, setTimeout just means wait n milliseconds, then run the function
It serves as a way to start an async task
 
@BenFortune @KarelG I finally solved the issue. In venueList.js it should be venues:state.venues.items and now if I do console.log(this.props.venues) it gives the data.
 
Yeah I got It now I did it thanks I called another function after work is done.Thank you @Neil
 
Hey. Not overly familiar with javascript and I'm struggling with something. I can apply a filter to an array like this - .filter(field => filters.indexOf(field) > -1).length == filters.length) - where filters in another array, of strings. But that only works with complete phrase matches, not partial matches
Partial matches needs something like includes() but you can pass an array into this. I'm struggling with the syntax to get this right
 
1:57 PM
Happy birthday @rlemon!
 
user1596138
Damn @BadgerCat that's what I came to say
 
user1596138
Oh it's been pinned heh
 
You guys are way too late
 
:(
I saw it pinned but I still wanted to say it myself
I still feel bad for forgetting last year
 
2:00 PM
 
2.9
 
2.9?
 
<3
 
Can someone please help me here: stackoverflow.com/questions/52186373/…
I spent almost 2-3 hours debugging but still no idea what is missing ?
I am new to redux but couldn't understand what I am missing redux action/component/reducer
 
user1596138
@stonerock Are you the asker on that question
 
user1596138
2:11 PM
Oh boy....
 
@LuckyKleinschmidt Can you please help me I am not able to find any solution even after spending 2-3 hrs debugging it
 
@stonerock Ask yourself what basic assumptions you're making to arrive at the conclusion of having json arrive in the fashion in which you're using
Then verify each basic assumption one at a time until you've proven them all correct: spoilers -- you won't
I know you've put a lot of time into this debugging, but if you haven't solved it by now, then you need to improve your debugging skills.
Consider this an opportunity to improve on them
don't rely on the solution dropping from the sky, especially because in my experience, this type of problem is almost always based on a bad configuration or assumption on your part
 
@neil I have done exactly which is shown in redux tutorials. What am I missing ? Please if you know the mistake please tel me buddy because I am getting headache now. I have spent lot of time on it and if you help me I may understand it and will not repeat it later. I think I am not connecting actions & reducers with components correctly.
 
user1596138
Someone has to debug it to find out
 
2:24 PM
No need to debug it is about accessing json data attributes.
 
user1596138
You just blatantly announced you're circumventing your question ban on a second account.
 
user1596138
Don't expect any help.
 
@stonerock I get where you're coming from because I've been there a thousand times
But honestly, I've got better things to do with my time
 
user1596138
@stonerock " 2-3 hrs debugging it" ... "No need to debug"
 
Just giving you some friendly advice. Take a step back, accept that this is going to be a bitch to debug, and do it like a detective might investigate a murder scene
 
2:26 PM
@Neil @LuckyKleinschmidt Sorry I will try to figure it out thanks for your time. I respect your time. Thanks once again
 
assumptions are your enemy! :)
Also, if you listen to one thing I've said, remember this: if you push through and debug it yourself, you will finish a better programmer than you were to begin with
 
@SyedSadaifRizvi Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
1 message moved to Trash can
@SyedSadaifRizvi Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. For posting large code blocks, use a paste site like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
 
2:43 PM
I have a problem. I am learning Javascript over more than 10 years. I understand a lot of things already. I also gave first grade students courses at the university.. But I catch myself very often that I don't understand await async, promises, observables..
I mean I understand them on paper but when it comes that I should implement them in real world apps, I have no idea and feel really dumb. Is there a way, good book or article to read that I finally >understand< these things and I am able to use them?
 
@Suisse sure, also - don't feel dumb - it's fine to now know things only when you acknowledge that you can learn.
Keep a beginner's mind.
Also, be sure you understand stackoverflow.com/questions/14220321/…
@snek let me know if you wanna sync on web locks or need a review
 
@LuckyKleinschmidt @Neil You banned my account ? You are so rude man ? First of all I was asking for help you could have not replied. First of all you banned my account now how can I learn ? where can I get help ?
 
user1596138
I have no power to ban anything or anyone.
 
user1596138
Don't break the rules and the mods won't punish you
 
Ok let it be now but any idea from where should I start I am clue less now from where should I start ?
How can I fix that problem ?
 
user1596138
2:50 PM
¯_(ツ)_/¯ I'm busy working
 
@stonerock this is not the place for that. Also both Neil and LuckyKleinsmith cannot ban your account. Moderators do (those with blue names or diamonds right to their name)
 
3:14 PM
Lol you were probably question banned for asking shit questions
 
hi
you don't appear to be manually banned, if you're banned at all it's just a throttle due to a history of poorly received questions.
 
the ban was on his 2nd account whom he used to circumvent a question ban
 
user1596138
No something else is going on
 
user1596138
Owners can see this it's deleted
 
3:18 PM
is anyone here really good with react
 
user1596138
He said he made the second account because his first is "blocked"
 
user1596138
@KarelG Oh okay, same page nvm
 
likely still the same scenario
 
define "really good with react"
 
3:23 PM
well don't have to be really good.. just knowledgable i guess
 
user1596138
Lots of us use React for work
 
user1596138
Ask away
 
3:39 PM
 
@BenFortune The question is not shitty you can see 2 answers from other users are also downvoted. So it is not easy problem if you think it is easy please can you help -> stackoverflow.com/questions/52184155/…
I couldn;t understand why please downvote without answering ? They should atleast answer and then downvote.
 
user1596138
3:56 PM
> They should atleast answer and then downvote.
 
user1596138
wtaf
 
Why would i post an answer to a question i find not useful or poorly researched
(that's what a downvote indicates)
 
it's @rlemon 's birthday
happy birthday
 
user1596138
Just for the sake of explaining to you..
 
user1596138
 
user1596138
3:57 PM
This is a horrible answer. Duh it got downvoted
 
user1596138
/me adds a third
 
user1596138
I'm not sure why your account still even works. You clearly circumvented your question ban and reposted the same question on a second account...
 
user1596138
Be grateful you can even log in and go spend your time improving debugging skills/rubber ducking your problem. You'd have solved it by now
 
@LuckyKleinschmidt I couldn;t understand why it is not working I tried each and every possible way. Please if you have 2-5min please tell me what is the fix I just want to print <Text>{this.props.venues.data[0].attributes.name}</Text> inside component.
 
user1596138
Wow
 
4:01 PM
<Text>undefined</Text>
 
@KevinB Yes I am getting this.props.venues.data[0].attributes.name as undefined
 
user1596138
So stop on a breakpoint and see why?
 
it's undefined in the object you are using.
Investigate that
What builds said object
Where in the process is it breaking down
 
All you're looking at is the end result currently
 
user1596138
4:03 PM
You're not going to git gud if you don't put in the work
 
there are several intermediary steps that you need to debug, we can't run the debugger for you in this case
it's certainly possible that someone could come along with far better redux knowledge than we have and spot a mistake
but... if we knew where in the process it was breaking down, we'd be able to help
 
@KevinB I tried this.props.venues.data.attributes.name doesn;t work
 
you're still looking at the end result
what sets this.props? what sets the data it depends on?
 
user1596138
I will share with you a screenshot of what I would do
 
All of that is in your question, but we can't place logs or debugger statements in there for you.
 
4:05 PM
@KevinB That's why I shared reducers and actions of VenueList.js in question and which seems to be working fine
 
In other words, follow the data.
 
Step one: Ensure the fetch is actually returning the data you want it to.
Then follow that data all the way to your view
Eventually you'll find the point where it becomes undefined
 
@KevinB Yes it is returning if I do console.log(this.props.venues) I see the entire data of api endpoint with metadata also
 
...
your question says you get venues: undefined
 
user1596138
4:07 PM
 
user1596138
This is called debugging.
 
user1596138
Notice how I am able to explore any aspect of this.props?
 
user1596138
I'm capable of helping myself because I used my devtools. You can easily solve your issue if you use your tools
 
@KevinB I have made edit in VenueList.js I have changes venues: state.venues.items
Now I am able to get props in VenueList.js
And this.props is an object
I am able to do this.props.venues.data and after that I am not able to go inside the nested json data
 
user1596138
Post the output of this.props.venus.data
 
4:12 PM
or better, the output of this.props.venues
(so that if there are quotes around it it'd be obvious)
 
user1596138
lol oh
 
Output of this.props is:
 
user1596138
That is how you plan to debug this app?
 
user1596138
this.props.venues.data[0].attributes.name
 
Output of this.props.venues.data :
 
user1596138
4:15 PM
Why are you acting like venues is an array in your question? It clearly is not
 
ew
the new chrome look is awful
 
Output of this.props.venues.data[0].attributes.name :
 
user1596138
Yeah because it starts empty..
 
user1596138
You just showed that.
 
@LuckyKleinschmidt @KevinB Check above screnshot
 
user1596138
4:17 PM
GET. SOME. DEVTOOLS.
 
user1596138
How can you sleep at night knowing all you do is console.log out to cmd
 
the value is undefined at the time your render occurs.
 
user1596138
Do you need assistance setting something up so that you can use an actual debugger on your react-native app?
 
user1596138
It's like the "teach a man to fish.." thing
 
user1596138
You want a fish or do you want to know how to get your own?
 
4:19 PM
Why this.props.venues.data[0].attributes.name is undefined ? This is giving me headache guys I am serious you are thinking that I am asking this without spending time but I have spent almost a day you can see previous chats
 
Have you tried using the dev tools like was suggested?
 
user1596138
You just answered the question. The answer is right here.
 
@LuckyKleinschmidt Yes I need some assistance for RN app
@LuckyKleinschmidt I answered my question what how ?
 
the official guide to debugging react native
Of particular interest, take a look at the Chrome Developer Tools section -> facebook.github.io/react-native/docs/…
 
debug js remotely is not opening I tried tons of time
 
4:23 PM
why did that link not work properly, the #?
 
Which link ?
I am getting -> This site can’t be reached
after clicking on debug js remotely
 
user1596138
I don't know how to do it with ANdroid simulator
 
@LuckyKleinschmidt I changed componentWillMount() to componentDidMount() still not working
@KevinB I know I how to debug in browser console but I am using android emulator RN app android
 
user1596138
@stonerock huh?
 
Does that thing not come with it's own debugger?
 
user1596138
4:26 PM
Okay I'm just giving you the fish
 
I have parse your JSON
 
user1596138
this.props.venues.data && this.props.venues.data[0].attributes.name
 
print(t.data[0].attributes.name) return Barasti Beach
 
user1596138
Make sure data exists before you try to reach into it. Now go away lol
 
user1596138
 
user1596138
4:28 PM
13 mins ago, by stone rock
Output of this.props.venues.data :
 
user1596138
Note that on the first render, this.props.venus.data is undefined.
 
user1596138
That is why when you try to use it it says cannot read property '0' of undefined, very plainly spelled out. Now you have code you can copy/paste. Now go and setup devtools
 
@nyconing The data is already parsed which is taken care by axios
 
No I just let know your json is fine...
 
@LuckyKleinschmidt Yes I understood that initial it is undefined and after that the data is set after fetching the data
 
user1596138
4:31 PM
So, you have your answer now right?
 
@LuckyKleinschmidt No How to fix that ?
 
user1596138
I literally pasted the code for you.
 
I think stone need the problem is solved instead of having answer..
 
Code where ?
 
user1596138
And explained it.
 
user1596138
4:32 PM
Bye felisha
 
5 mins ago, by Lucky Kleinschmidt
this.props.venues.data && this.props.venues.data[0].attributes.name
 
response.data.data = response.data.data.map((user) =>{
  return console.log({ user.id : user.name});
});
and they literally asked why it's returning undefined
 
I want to display this.props.venues.data[0].attributes.name inside <Text>
Like this -> <Text>{ this.props.venues.data[0].attributes.name}</Text>
 
user1596138
I think he needs kicked
 
user1596138
It's just spam now
 
user1596138
4:40 PM
!!afk better things to do
 
Hey
Was trying to get an answer of jquery related question
what will happen if I bind the click event on class and assign that to parent and its one of child div
anyone please
 
4:55 PM
@LuckyKleinschmidt Check my code what am I doing wrong ?
 
@stonerock LuckyKleinschmidt is afk: better things to do
 
class VenueList extends Component {

    componentDidMount () {
        this.props.fetchVenues();
    }

    render() {

        return (
            <View style={styles.container}>
                <View style={styles.boxcontainer}>
                    <Image
                    style={styles.img}
                    source={{ uri: 'https://www.dike.lib.ia.us/images/sample-1.jpg/image' }}
                    />
                    <View style={styles.card}>
                        <Text> {this.props.venues.data[0].attributes.name}</Text>
Still getting undefined for above code
 
@stonerock did you print the response
 
@VishalPachpande I am getting undefined
 
@stonerock can you show me the response
 
4:59 PM
@VishalPachpande check this i.stack.imgur.com/UvvF0.png
 
@stonerock {this.props.venues && this.props.venues.data[0].attributes.name} put this line
 
@VishalPachpande this line doesn;t display anything -><Text>{this.props.venues.data && this.props.venues.data[0].attributes.name}</Text>
Code:
class VenueList extends Component {

    componentDidMount () {
        this.props.fetchVenues();
    }

    render() {

        return (
            <View style={styles.container}>
                <View style={styles.boxcontainer}>
                    <Image
                    style={styles.img}
                    source={{ uri: 'https://www.dike.lib.ia.us/images/sample-1.jpg/image' }}
                    />
                    <View style={styles.card}>
                        <Text> {this.props.venues && this.props.venues.data[0].attributes.name}</Text>
See above code @VishalPachpande
 
@stonerock {this.props.venues && this.props.venues.data[0].attributes.name}
 
@BenjaminGruenbaum it's gonna be a while before there's anything to review lol
i just started reading the spec
i'll probably steal from chromium's impl
 
@VishalPachpande Yes see I have made changed but nothing is printed see screenshot below:
 
5:05 PM
@snek if you need a connection Domenic and Myles told me about it over a year ago when they first implement and they're both familiar.
 
heh i do enjoy bothering domenic
 
@VishalPachpande I have also add it inside componentDidMount()
 
@stonerock I saw your above text that you have changed componentDidMount from willMouont
 
@VishalPachpande Yes
It should be componentDidMount() right ? Not componentWillMount()
 
@stonerock but if you can see its giving undefined at first time and second time you are getting json response
 
5:09 PM
@VishalPachpande yes
 
@stonerock so you have to handle that undefined
 
@snek you do :D ?
 
@VishalPachpande Yes how can I do that ?
 
@snek I don't know how familiar you are with Domenic, be very careful disagreeing with him. He's a smart and nice guy but he gets a lot of bullshit and it makes it hard for him to discern disagreements and personal attacks because he gets a bunch of the latter.
 
@stonerock can you send me response once AGAIN
 
5:12 PM
@VishalPachpande data:
{
  "data": [
    {
      "type": "venues",
      "id": "nb",
      "attributes": {
        "name": "Barasti Beach",
        "description": "Barasti Beach is lotacated in the awesome barasti beach",
        "price_range": "$$$",
        "opening_hours": "10:30-12:40/16:00-2:00",
        "organization": {
          "id": "GD",
          "legal_name": "Barasti",
          "brand": "Barasti"
        },
        "place": {
          "address": "Le Meridien Mina Seyahi Beach Resort & Marina, Dubai Marina - Dubai - United Arab Emirates",
@VishalPachpande It is very difficult the solve this issue
 
@stonerock not this the log
 
Check screenshot above
 
@stonerock here you are trying to access the data from props which you are assigning in render method
 
@VishalPachpande Yes I want to do this -> <Text>{this.props.venues.data[0].attributes.name}</Text>
How can I do that ?
 
5:22 PM
I want to output Barasti Beach i.e attributes.name inside <Text>
Any idea how can it be done ?
 
@stonerock instead of using props directly handle the response in copmponentWillReceiveProps method and assign that field to state and assign that state in <text>
 
Why to create state variable any other idea ?
Can it be done without state variable ?
 
@stonerock we can but for that you have handle the undefined reponse
 
@stonerock try to find from which key its giving you undefined
 
5:27 PM
@VishalPachpande How can I do that in react native
 
@stonerock once you find it just put a simple check overthere
 
Check where ?
 
@stone
@stonerock check means if condition
@stonerock Like this.props ? this.props.venues.data[0].attributes.name:' '
 
1 message moved to Trash can
@stonerock Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
 
@VishalPachpande This doesn't work ->
<View style={styles.card}>
{this.props.venues.data && this.props.venues.data[0].attributes.name ?
<Text> {this.props.venues.data[0].attributes.name} </Text> : ''}
</View>
 
5:34 PM
@stonerock {this.props ? this.props.venues.data[0].attributes.name:""} try this
 
@VishalPachpande @LuckyKleinschmidt check screenshot below:
Still getting error
 
@stonerock shift your fetchVenues method in contructor and try once
 
@BenFortune @VishalPachpande see screenshot below:
 
@stonerock {this.props.venues.data} put this line want to check some
 
5:50 PM
class VenueList extends Component {

    componentDidMount (){
        this.props.fetchVenues();
    }

    render() {

        console.log(this.props.venues)

        return (
            <View style={styles.container}>
                <View style={styles.boxcontainer}>
                    <Image
                    style={styles.img}
                    source={{ uri: 'https://www.dike.lib.ia.us/images/sample-1.jpg/image' }}
                    />
                    <View style={styles.card}>
 
@stonerock what you are getting console.log(this.props.venues) here
 
hard to trust console.log, may be showing you what it currently equals, not necessarily what it equaled when you did console.log, the error is trying to access props.venues.data[0], so dig deeper into that
 
@stonerock put this this.props.venues instead {this.props.venues.data ? this.props.venues.data[0].attributes.name:""}
 
change this.props ? to this.props && this.props.venues && this.props.venues.data && this.props.venues.data.length > 0 ?
 

« first day (2881 days earlier)      last day (2073 days later) »