you are viewing a single comment's thread.

view the rest of the comments →

[–]jingles[S] 1 insightful - 2 fun1 insightful - 1 fun2 insightful - 2 fun -  (6 children)

i dont need json... i am old school... my preference is similar to how data is received in an http response, "variablename: value"

i am quite happy with something like that.. i just want to be able to request a webpage and to receive it;s header and body.

can you point me to how to do that? if it is the lowest possible level way to do it, i am all the happier.

fuck json.

[–][deleted] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (5 children)

Sure, fetch is pretty easy to work with actually

The simplest example is just:

const response = await fetch('http://127.0.0.1:8000/some_path')

This will request whatever you are serving at that address, and the entire HTTP response is stored in the variable with accessible fields.

You can access the header and body and whatver else you need through the response object

if(response.status === 200)
{
  console.log(response.body)
}
else
{
  alert("My penis hurts!")
}

or however you want to handle the response

[–]jingles[S] 1 insightful - 2 fun1 insightful - 1 fun2 insightful - 2 fun -  (4 children)

//does a semicolon go on the end of this line? or not?
const response = await fetch('http://127.0.0.1:8000/some_path')

if(response.status === 200)
navigate("/some_other_route", { replace: true }); 
else
alert("My penis hurts!");

//again, i guess that no semicolon goes here? like in C?
console.log(response.body)

does the above look right?

[–][deleted] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (3 children)

Javascript you can do it either way, but you do not need the semicolons, that looks right except for the lack of curly braces after the 'if' statement, i'm not sure if javascript lets you leave them out for 1 liners, but it probably does

[–]jingles[S] 2 insightful - 2 fun2 insightful - 1 fun3 insightful - 2 fun -  (2 children)

i am so comfortable in C language.. my first C compiler was the microsoft quickC for dos, i bought it in 1991 from egghead software for $70.00

i have done a little bit of reading about javascript and i get the hint that javascript was sortof slapped together and some of it is held together with duct tape. that is my impression after reading it.

omg i wish that i could embed C straight into a fucking browser.

[–][deleted] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (1 child)

i have done a little bit of reading about javascript and i get the hint that javascript was sortof slapped together and some of it is held together with duct tape. that is my impression after reading it.

Yes, I feel the same way about javascript, its terrible, especially if you are used to a real systems language like C

omg i wish that i could embed C straight into a fucking browser.

Technically you can...C can compile to WASM, but I'm not sure how mature that ecosystem is for C in terms of the WASM bindings

[–]jingles[S] 1 insightful - 1 fun1 insightful - 0 fun2 insightful - 1 fun -  (0 children)

i looked at web assembly.. nah.

anyways, i just want to find a super basic way to read an html header and body... i think that you just gave it to me a few posts back..

gonna get some rest and go at it again.

truth is, my health is not good, and you know.. my future aint bright.. but i used to really like coding.

truth is that i am subject to walking off the edge of this planet any time now.

but thanks for your kind inputs.

edward scissorhands.