« first day (4670 days earlier)      last day (503 days later) » 

00:05
yes
00:24
So what command is it? I looked on the command page but can't find it
fetch
!!w3schools ai
@ai Don't use w3schools.
!!mdn ai
01:11
||fetch
@ParkingMaster 'SyntaxError: Unexpected identifier' Logged: [ ] Took: 0ms
||help fetch
Command documentation and syntax can be found here.
01:13
@KevinB doesn't look like it's a command
||man fetch
No manual entry for fetch
01:36
wdym
!!mdn uses fetch
!!w3schools sucks
@sucks Don't use w3schools.
@KevinB lol no I meant for @JamesBot
Is there a way to make an HTTP request with a a command (like echo)
01:53
of course not
02:20
Oh ok haha I didn't think so
maybe I could be the first to create it
||learn request ||>fetch("{1}",{method:"{2}",body:JSON.stringify({a}))
request has been added
||>fetch("https://google.com",{method:"{2}",body:JSON.stringify(google.com))
||status
I am currently alive!
02:27
||>console.log(1)
@JBis james isn't outputting anything again
||unlearn request
request has been unlearned
02:41
||learn request ||>let request = {method:"{2}"}; if ("{2}".toLowerCase().trim() != "GET") request.body = JSON.stringify("{3}".startsWith("{3") ? {} : JSON.parse({{3}})); fetch("{1}",request);
request has been added
||request httpbin.org/post POST "'parameter': 'value', 'example': 1"
||>let request = {method:"POST"}; if ("POST".toLowerCase().trim() != "GET") request.body = JSON.stringify("'parameter': 'value', 'example': 1".startsWith("{3") ? {} : JSON.parse({'parameter': 'value', 'example': 1})); fetch("https://httpbin.org/post",request);
||unlearn request
request has been unlearned
02:52
||learn request ||>let request = {method:"{2}"}; if ("{2}".toLowerCase().trim() != "GET") request.body = JSON.stringify("{3}".startsWith("{3") ? {} : JSON.parse({{3}}.replace(/\'/gi, '"'))); fetch("{1}", request).then((response) => console.log(response));
request has been added
||request httpbin.org/post POST "'parameter': 'value', 'example': 1"
||>let request = {method:"POST"}; if ("POST".toLowerCase().trim() != "GET") request.body = JSON.stringify("'parameter': 'value', 'example': 1".startsWith("{3") ? {} : JSON.parse({'parameter': 'value', 'example': 1}.replace(/\'/gi, '"'))); fetch("httpbin.org/post", request).then((response) => console.log(response));
||unlearn request
request has been unlearned
02:54
||learn request ||>let request = {method:"{2}"}; if ("{2}".toLowerCase().trim() != "GET") request.body = JSON.stringify("{3}".startsWith("{3") ? {} : JSON.parse({{3}}.replace(/\'/gi, '"'))); fetch("{1}", request).then((response) => console.log(response));
request has been added
there we go
||request httpbin.org/post POST "'parameter': 'value', 'example': 1"
||>let request = {method:"POST"}; if ("POST".toLowerCase().trim() != "GET") request.body = JSON.stringify("'parameter': 'value', 'example': 1".startsWith("{3") ? {} : JSON.parse({'parameter': 'value', 'example': 1}.replace(/\'/gi, '"'))); fetch("https://httpbin.org/post", request).then((response) => console.log(response));
||unlearn request
request has been unlearned
02:59
||learn request ||>let request = {method:"{2}"}; if ("{2}".toLowerCase().trim() != "GET") request.body = JSON.stringify("{3}".startsWith("{3") ? {} : {{3}}); fetch("{1}", request).then((response) => console.log(response));
request has been added
Final test
||request httpbin.org/post POST "'parameter': 'value', 'example': 1"
||>let request = {method:"POST"}; if ("POST".toLowerCase().trim() != "GET") request.body = JSON.stringify("'parameter': 'value', 'example': 1".startsWith("{3") ? {} : {'parameter': 'value', 'example': 1}); fetch("https://httpbin.org/post", request).then((response) => console.log(response));
Boom
James can now send requests
This will only work when the command output starts working again though
 
5 hours later…
07:38
@ParkingMaster because james doesnt listen to james
you cant do what you want
at least not with James :)
 
1 hour later…
08:41
Wonderful day! ^^
The main issue I am trying to solve is that parent and subclass have a property with the same name. Is it possible to somehow merge the subclass property with the parent?
One idea I have is to have a constructor in the parent which would set a prototype value, but it does not work: jsitor.com/JVMU5NzK8W
 
4 hours later…
12:36
Regarding the above, found the solution in another channel (Libera, ##programming, by member Booster2ooo): playcode.io/1547149
@Wietlol ohhh man
I guess there is no way to make an http request with james then
I am still trying to realize how it works exactly and why this.__proto__.opts did not work in B
@Artfaith the jsitor you linked was not found
It was a few hour ago.
I have no idea why it does not work now.
Oh ok you could use JSbin or codepen
12:39
Mayhap they have some limited storage time setup.
So you just want to merge the child's attribute/property with the parent?
Thank you, sure, but I was trying to find something with a dark theme.
And with more than 1 file JavaScript like CodeSandbox but simpler.
@ParkingMaster This was the main purpose indeed, so to have some kind of default property values in the parent and allow the child to override some of them.
Seems easy enough: store the child's target class, remove the child's target class, append the stored class to the .parentElement
So, now, with a few values passed to the subclass/child constructor, the values will get merged, and the full set will stay intact.
@ParkingMaster I am sorry, "parentElement"?
@Artfaith yes you can access the parent from the child
12:44
There's no reason to work with the DOM but only class/subclass of ES6 syntax.
@Artfaith what do you mean?
May I ask is there any example which would demonstrate the logic you mention?: "store the child's target class, remove the child's target class, append the stored class to...'?
@ParkingMaster There's no "parentElement" there or any Nodes like developer.mozilla.org/en-US/docs/Web/API/Node/parentElement.
It's just a plain ECMAScript6 syntax code or the sugar wrappers around the underlying Object methods I am still trying to gain knowledge about.
By "parent" class I meant the one the subclass extends. E.g. class B extends A, where A is the super-class (parent if an instance), and B - sub-class (child if an instance).
Oooh haha I thought you meant the DOM element's class 😂
Sorry I don't use classes/subclasses that often so I was kind of confused
That's kind a subject you might be interested, too!
I will practice it one day, lol
12:53
@Artfaith 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
@JamesBot >:P
Oh... I shared it here so it would not get removed like above.
So you want to merge the B subclass with the parent (A) instead of "extend"ing it?
@Artfaith triple backticks don't work in chat you just have to click the "fixed font" button before sending
You're correct. I wanted to merge some property indeed, so to allow the child have its own custom values and allow it to get pre-defined default values from the extended one.
In the result, the child constructor like "new B({a: 3})l" would result in {a: 3, b: 1} where the b property was in the parent prior merging.
More to that, this allows for deep merging and override deeper values if required in the option hierarchy.
Like: const b = new B({a: {c: 2}}); ~ b.test == {a: {c: 2, d: 3}, b: 1}; // In the case test is the "default" property being merged.
13:00
Oh, ok so you want anything created from B(), to merge all those properties to the created A() instead of calling B() and using that's properties
Probably like that, yes. So, in the result, some property is filled with both default and custom values in the child.
Yeah I understand now
That is actually a really hard question
What you have to do is store all of B's custom properties (before it's created) in another property called custom, then after B() is called, loop through all of the sub properties in .custom, and append them to A's properties when it is created
I tried to make my answer simple enough but let me know how it goes
13:55
Hi,
@Regokonda 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.
I am trying something in typescript and trying to find a solution. I have an object Address{'30 Collins st','Burnley','Sydney','NSW',3000 } how can I convert this into a string with full address
 
1 hour later…
15:10
@Regokonda like Javascript, there is a simple property called .toString(). Just call .toString() on the Address object. It should work
15:45
@ParkingMaster you can make a http request with Wietbot
its just not connected to the internet, so you will probably get a timeout
15:56
@ParkingMaster .toSting() on a plain object produces the string "[object Object]"
@Regokonda That's not really a valid object. It's missing keys. If you had some keys, like {key1: '30 Collins st', key2: 'Burnley', key3: 'Sydney', key4: 'NSW', key5: 3000 } then the easiest way convert it to a regular address with string template:
||> const address = {key1: '30 Collins st', key2: 'Burnley', key3: 'Sydney', key4: 'NSW', key5: 3000 };

const formattedAddress = `${address.key1} ${address.key2}
${address.key3} (${address.key5}) ${address.key4}`;

console.log(formattedAddress);
@VLAZ-onstrike- undefined Logged: [ '"30 Collins st Burnley \n Sydney (3000) NSW"' ] Took: 0ms
If you just want to convert the entire object to a string, then use JSON.stringify
||> const address = {key1: '30 Collins st', key2: 'Burnley', key3: 'Sydney', key4: 'NSW', key5: 3000 };

console.log(JSON.stringify(address));
@VLAZ-onstrike- undefined Logged: [ '"{\"key1\":\"30 Collins st\",\"key2\":\"Burnley\",\"key3\":\"Sydney\",\"key4\":\"NSW\",\"key5\":3000}"' ] Took: 0ms
If you're on node, check what the option there is to serialise object to JSON.
 
3 hours later…
18:51
@Wietlol that's cool. Don't know why James can't do it
@VLAZ-onstrike- I don't know typescript so sorry for the mistake. Obviously toString doesn't work on an object in Javascript, but it seems to work right in typescript
||request httpbin.org/post POST "'parameter': 'value', 'example': 1"
||>let request = {method:"POST"}; if ("POST".toLowerCase().trim() != "GET") request.body = JSON.stringify("'parameter': 'value', 'example': 1".startsWith("{3") ? {} : {'parameter': 'value', 'example': 1}); fetch("httpbin.org/post", request).then((response) => console.log(response));
||>let request = {method:"POST"}; if ("POST".toLowerCase().trim() != "GET") request.body = JSON.stringify("'parameter': 'value', 'example': 1".startsWith("{3") ? {} : {'parameter': 'value', 'example': 1}); fetch("httpbin.org/post", request).then((response) => console.log(response));
 
4 hours later…
23:13
@ParkingMaster yeah James won't respond to James
Answer the Vanotton's question
23:33
|| > console.log('Olá')
Invalid command! Did you mean: 3, c, d? Try help for a list of available commands..‍.‍.‍.‍.‍
||>console.log('Holla')
|| help
Command documentation and syntax can be found here.
|| sudo debug enable
@Vanortton You are not authorized to administer this command
23:36
|| define hello
noun - "Hello!" or an equivalent greeting.
|| eval console.log('Hello World!');
@Vanortton undefined Logged: [ '"Hello World!"' ] Took: 1ms
|| eval fetch('https://nfe.io/docs/app/uploads/2020/10/cpf-api.txt').then(resp => resp.json()).then(resp => console.log(resp));
@Vanortton 'ReferenceError: fetch is not defined' Logged: [ ] Took: 0ms
23:41
|| funfact
Thomas Edison, acclaimed inventor of the light bulb, was afraid of the dark.
|| joke
What did the Java code say to the C code?
You've got no class.
|| obama Hey, I'm Obama!
23:44
Ok, it's really fun

« first day (4670 days earlier)      last day (503 days later) »