« first day (4119 days earlier)      last day (812 days later) » 

7:05 AM
Hi All
Im using axios in my node js to make some GET calls
its working fine but there is some problem
Im not getting all the headers in the response.header property, whereas when I make the same call using postman, Im getting all the expected headers
Im looking for Location header in the response of axios GET which Im not getting
but the same call in postman give header.location
I have tried adding Access-Control-Expose-Headers to my middleware
 
7:26 AM
@MasoodAlam Please don't post unformatted code - use the up arrow to edit your post, then hit Ctrl + K to format the code in that post. See the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
@MasoodAlam 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.
For posting large code blocks, use a paste site like like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
1 message moved to Trash can
@MasoodAlam Please don't post unformatted code - use the up arrow to edit your post, then hit Ctrl + K to format the code in that post. See the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
For posting large code blocks, use a paste site like like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
1 message moved to Trash can
 
I am trying this code but it does not returns anything;

const fs = require('fs')

let data = ""
fs.readFile("./static/file.json", 'utf-8',(err, file) => {
  if(err){
    console.log("Unable to read file.");
    console.log(err)
  }
  else{
    const data = file
  }
})
console.log(data)
 
 
3 hours later…
10:28 AM
Classic
6264
Q: How to return the response from an asynchronous call

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

 
10:42 AM
Suppose I have a webpage in which some images have src attribute "dev.cats.com" and I'd like to change all those src attributes to "cats.com" -- is there a Chrome plugin for this?
 
 
2 hours later…
12:50 PM
Hi all
@BenFortune Reading through this. Really thorough explanation of async in JS
Thanks for sharing
 
@Alex It is the most frequent question. Although, I'm not sure exactly how that ranking is derived - I assume from the number of incoming links/duplicates. At any rate, see also Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference
 
 
2 hours later…
3:03 PM
is it possible to style a div based on the width of its parent using something like a media query?
Like we can use @media (max-width: 1000px) {
background-color: yeet;
}
but that's the window width--is there something analogous for arbitrary divs?
 
3:25 PM
@VLAZ I believe it
It's a challenging subject in any language. C# has lots of articles about it
 
4:01 PM
New UI update to the main site?
 
4:12 PM
if you want to call it that
@duhaime not that i'm aware of
 
4:26 PM
what changed
 
score, answers, and views were turned into footnotes
 
isn't that the most important info
 
depends on who you ask
 
i guess you don't see it when you search from google
 
that's effectively my argument against it
The people who don't need to see score, are more often than not coming from google anyway
tailor the view we get to the people who use the view.
 
4:40 PM
🤮
 
4:53 PM
Say I have a couple of pages with the Bootstrap 5 navbar. Is there an easy way to have them all auto update across all pages, or would I just have to edit them on each page
 
you mean, auto show as active on the tab that corresponds to the currently viewed page?
 
I'm reading an explanation for the begginers: nodejs.org/en/knowledge/javascript-conventions/…. Could be a code formatting mistake in there? myfunc
  .apply(obj, arguments)
  // concat arguments onto the
  .Array.prototype.concat.apply([1, 2, 3], arguments);
 
@lafleur 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.
 
.Array doesnt make sense to me, is myfunc returning an object with an Array property?
i'd assume not, and that you intended that to do something else
!!mdn concat
 
5:00 PM
wow, it's actually that way in the node.js docs. That looks like an error
it's... also quite an absurd example
there's no case where you'd need to use .apply with array concat
 
myfunc() console logs some values.
 
my issue is iwth the .Array.prototype.concat.apply([1, 2, 3], arguments); line
the . at the start doesn't belong,
unless myfunc returns {Array: Array}
so, i guess a better way to put this is what are you looking to know?
maybe i can explain it better or help you understand the bit you're missing better than these docs can.
 
Maybe the writer thought of "myfunc .apply(obj, arguments);" then "Array.prototype.concat.apply([1, 2, 3], arguments);", as I see in the explanation paragraph on top.
 
What that example was trying to do was show that arguments could be used in place of an array in some scenarios
aka not requiring Array.from or spread
but all the examples they gave are things you'd generally not do
except for the first one
myfunc.apply(obj, arguments)
that's a valid example
 
@KevinB That period looks awkward to me too.
I was thinking there could be some mistake but I was not sure, I'm a beginner.
 
5:10 PM
My bet is the example was intended to be:
myfunc
  .apply(obj, arguments)
// concat arguments onto the
Array.prototype.concat.apply([1, 2, 3], arguments);

// turn arguments into a true array
const args = Array.prototype.slice.call(arguments);

// cut out first argument
args = Array.prototype.slice.call(arguments, 1);
no idea why .apply in the first case got it's own line, but meh
myfunc.apply(obj, arguments);

// concat arguments onto the
Array.prototype.concat.apply([1, 2, 3], arguments);

// turn arguments into a true array
const args = Array.prototype.slice.call(arguments);

// cut out first argument
args = Array.prototype.slice.call(arguments, 1);
 
Yes, this is what I was thinking too. Thank you, I can live more peacefully now =]
 
all 4 examples are effectively showing you the same technique
just that arguments is a valid argument for .call and .apply, because they don't care if the value is a real array
that can also be true of methods you create, or methods from libraries
but it's typically best to be consistent and always pass arrays
 

« first day (4119 days earlier)      last day (812 days later) »