« first day (3751 days earlier)      last day (1180 days later) » 

user14692552
6:02 PM
Damnit didn't work
 
user14692552
<script>
const getItems = () => {
    return fetch(fullUrl, {

    method:'GET',
    headers: {
        'Content-Type': 'application/json',
    },
    body: JSON.stringify(data),
    })
    .then(response => response.json())
    .then(data => {
        console.log('Success:', data);
    })
    .catch((error)=>{
        console.error('Error:', error);
    });
}
</script>
 
@codingdreaming wdym?
if response isn't valid json repsonse.json will throw
 
user14692552
When I look in the console to check the network response. IT is in XML
 
try Accept: application/json?
content-type only means the type of the request body, not the requested response
 
user14692552
Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
 
user14692552
LMAO
 
user14692552
You promised me JSON and Sent XML
 
wtf lol
 
user14692552
listening to this whole way through... kind of a banger
 
lol
 
user14692552
6:19 PM
const getItems = () => {
    return fetch(fullUrl, {

    method:'GET',
    headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
  },
    body: JSON.stringify(data),
    })
    .then(response => response.json())
    .then(data => {
        console.log('Success:', data);
    })
    .catch((error)=>{
        console.error('Error:', error);
    });
}
 
user14692552
@makadev updated the header and still nothing.
 
@codingdreaming does your endpoint actually deliver JSON?
 
LMFAO
 
user14692552
Yes.
 
user14692552
6:21 PM
It was doing it with my jQuery just fine
 
user14692552
8
Q: Fetch -API returning HTML instead of JSON

user6761897I have a Spring REST API which I've tested on Postman and it returns perfectly valid JSON. However when I call the same API on my front-end React Code it returns HTML. This is the function, I'm using to call the API, export function run(engine, mediaId, owner, target, access){ let url = engine...

 
user14692552
Idk why they said "HTML" I am assuming they meant XML as well, but they said same as you to make sure the headers are right, and still same issue
 
try credentials: 'include'
  return fetch(fullUrl, {
         credentials: 'include'
 
hrmm.. I think credentials shouldn't be a problem, accept is on the safe list
 
user14692552
Doesn't change anything. Nothing is returned to console
 
user14692552
6:25 PM
When I added headers and body it doesnt even show anything in console nor any errors
 
@makadev iirc fetch doesn't send cookies cross origin by default
 
@JBis I wonder if I asked the back pressure question
 
not really sure what your question was
@codingdreaming so how do you know it's not returning json?
try changing it to response.text() and see what it returns
 
@JBis ah ye, cookie header needs credentials permission as it seems.. TIL
 
they should really change that, "credentials" doens't mean anything about cookies
 
user14692552
6:29 PM
<script>

const getItems = () => {
  return fetch(fullUrl)
    .then(response => response.json())
    .then(data => console.log(data))
}
getItems();
</script>
 
should be cookies: 'include
@codingdreaming getItems is useless in this example
 
user14692552
No it isnt
 
what did you get when you changed it to .text()?
@ShrekOverflow not really sure what your question was
 
user14692552
How is it useless? I create the function getItems so I need to call it
 
user14692552
without calling it nothing is returned
 
6:32 PM
@codingdreaming it only prints to console
thats why it's useless
 
user14692552
But doesn't even print to console without it
 
user14692552
So therefore it is useful so I can actually see what is returning to the console
 
fetch(fullUrl)
    .then(response => response.json())
    .then(data => { console.log(data);  return data; })
 
user14692552
@JBis .text() still returns
 
or better, log it when you get the return
 
user14692552
6:33 PM
<?xml version="1.0" encoding="utf-8"?>
 
is the data there? just in xml?
 
user14692552
Yes
 
user14692552
Thats what I have been trying to get at
 
Ok. Open your network console, make the request in jquery, then make it in vanilla and compare. See whats different.
 
user14692552
Only noticeable difference
 
user14692552
6:39 PM
The Type for the fetch is fetch instead of XHR
 
right click on the jquery one and "Copy as Fetch" then look at it
 
user14692552
and the raw response data in the network tab is XML for the fetch vs the jquery being JSON
 
user14692552
Don't roast me but I am in Chrome on this right now, but using Edge. I find edge to be good
 
it probably is (assuming you are using the chromium version)
you still should be able to copy as fetch, if not switch to Chrome
 
user14692552
Ok hold on
 
user14692552
6:46 PM
NP++ crashed on me and I lost my jquery response have to rewrite rq
 
user14692552
I copied as fetch now what
 
wouldn't it be nice if the IDE autosaved?
WebStorm does :D
 
user14692552
NP++ isn't an IDE -.- Im using VSC but also NP++
 
user14692552
I have so much shit open rn
 
user14692552
Damn so the code I posted earlier where you guys roasted me for using jQuery and fetch (the type returned in network console is also : fetch) and the response is in JSON
 
6:54 PM
Has there been any focus in tc39 for proper math support in JS? I have inferred from some quick demonstrations it isn't at the level of Python(this is probably just speed/convince.)
 
user14692552
wait now its saying type XHR for the old code
 
@Lime whats proper math?
@codingdreaming copy as fetch
 
@JBis SymPy, mpmath, llvmlite are all libraries that have loose equivalents in JS
 
user14692552
fetch("sharepointurl/_api/web/lists/getbytitle('WeeklyReport1')/items?$select=Team,WeekOf,OffensiveReport,DefensiveReport,SpecialTeamsReport", {
  "headers": {
    "accept": "application/json; odata=verbose",
    "accept-language": "en-US,en;q=0.9",
    "if-modified-since": "Fri, 22 Jan 2021 18:54:01 GMT",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-origin",
    "x-requested-with": "XMLHttpRequest"
  },
  "referrer": "sharepoint list url",
  "referrerPolicy": "strict-origin-when-cross-origin",
 
proper integer vs float vs double support I believe is missing in JS
 
user14692552
6:57 PM
That is from ^
 
you can emulate it but its quite slow I believe
 
user14692552
var fullUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('WeeklyReport1')/items?$select=Team,WeekOf,OffensiveReport,DefensiveReport,SpecialTeamsReport",
$.ajax({
  url: fullUrl,
  type: "GET",
  headers: {
      "accept":"application/json; odata=verbose"
    },
  success: renderData,
  error: onError
});

function renderData(data) {
  fetch('template.mustache')
    .then(response => response.text())
    .then(template => {
      const rendered = Mustache.render(template, data);
 
user14692552
I dont even want to touch what I just sent its so ugly and honestly dont know where it came from
 
@codingdreaming try "accept": "application/json; odata=verbose", in your fetch
 
user14692552
thats what I was thinking
 
7:00 PM
@Lime what are you trying to do? in js there is only one number type
 
which is unfortunate
take a look at mathics.org & Mathematica and you will see what I am trying to do
Symbolic math equations, simplify, evaluate, summations
The pattern matching in JS is really rudimentary compared to other languages unfortunately
 
@Lime There is BigInt. I think they are working on BigDecimal
 
@Lime python tends to be the more science analytics language
but its possible in js
 
its rarely done in JS in my experience
I wish it wasn't that way
 
<script>
 var fullUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('WeeklyReport1')/items?$select=Team,WeekOf,OffensiveReport,DefensiveReport,SpecialTeamsReport";

const getItems = () => {
  return fetch(fullUrl, { credentials: "include",
                        headers: {
                            "Content=type": "application/json",
                            "accept": "application/json; odata=verbose",
                        }

  })
    .then(response => response.text())
so I did that @JBis and
Uncaught (in promise) TypeError: Failed to execute 'fetch' on 'Window': Invalid name
 
7:04 PM
@Lime That's not really available in Java or C# as far as I'm aware. JS isn't really an exception - some languages are used more for evaluating equations. Some aren't.
 
@bigchungus why you have two accounts?
 
@VLAZ thxs I recalled they added something. Yes you are right Python just seems to very popular in the community for math equations for some reason.
 
@bigchungus "Content=type"
 
I want a Symolic JS engine like Mathematica running in the browser but I have been unable to find it.
mathics.org is really close but you need the backend
 
I really don't know tbh haha
was tired of being bigchungus
 
7:07 PM
@Lime A bit of a self-reinforcing loop there. Python is good with math and science stuff. So more maths and science people use it. Then they make more maths and science libraries and features for Python which makes it even better suited to them
 
but just realized you can change your name
@JBis guess what
"accept": "application/json; odata=verbose",
was the last puzzle piece
that was too stressful for that little piece missing
Thank you.
 
shitty api, not your fault
 
the type is still fetch, but all I care about is the response being in JSON.
Now time to haze myself and try to learn this mustache.js library
Much appreciated to everyone in here that aided me on that
Woah never seen this before in JSON responses..

<div class=\"ExternalClass(ridiculously long string of numbers)\"><p>(My values)​<br></p></div>
 
vlaz is a last name? Because urbandictionary and google comes up with few to little results
 
It's not a name. Not that I know of, at least.
I've been surprised before by what I thought was a nonsense collection of characters was actually a word in some language.
I'm scared to look at Urban Dictionary.
Hmm, first time I googled this username. There is apparently some musician on Soundcloud with the same name.
It's also in all caps.
 
7:17 PM
It has an interesting symmetry when pressing it on the keyborad
in dvorak*
 
I was just going to say that I don't see it in QUERTY
Neat, it's a bit of a triangle across the entire keyboard
Yeah, I found several people with apparently the real (last?) name Vlaz.
 
were you here when rlemon and the gang was here
I miss rlemon :'(
 
Not really. I've seen rlemon's posts on SO but I'm relatively new to chat. Started coming in last year.
 
admins had to break up the chat 1 to many times is I'm guessing what happened
BigInt is still not supported by all browser
do you think JavaScript will get support for complex numebrs
 
Still not? I hadn't checked its support but I assumed it's all the ones that matter, at least.
 
7:31 PM
It appears not to support imaginary numbers but everything else yes
 
As for complex numbers, I suspect the answer is "yes, eventually" but I don't see it for a long time. I don't think TC39 focus that much on the science-y stuff. Which is a bit of a problem in this case.
Perhaps there is a dialect of ECMAScript that deals with this but I'm not familiar with the JS extended family.
 
its very disappointing to me that imaginary numbers were left out
other then that I'm pretty sure BigInt makes it on par with Python
see JS was a template language originally and now we added on all this fancy features
 
7:50 PM
@JBis so I have made my mustache.js template. And the vanilla JS is doing exactly what I want to fetch the JSON data.

For example I have "Team" : "Raiders".
To append "Raiders" to the mustache {{Team}}, Is it achievable without jQuery? The only examples I can seem to find involve jQuery. which after learning from you I would like to avoid
Or anyone for that matter, if you have any input I would appreciate it
 
8:05 PM
@Lime The history of JS can be summed up with "insanity with fancy features"
 
@bigchungus idk how mustache works but wouldn't it just be Team + "Raiders"
or {{Team}} Raiders
 
 
1 hour later…
9:19 PM
Limon
This is why I hate things with API. All the examples I can find to do whatever I need to do are all static and of course I am fetching mine, so it makes it more difficult for me to figure out how to populate
 
9:33 PM
Better way of wording it. If I am using a fetch, can I still call a success function?
TO populate the mustache
1
Q: using mustache with json from remote api url

genokimustache documentation describes using local typed json source eg like mustache demo linked below .. http://mustache.github.com/#demo however mustache documentation does not describe syntax for using remote linked json source. i was able to successfully copy and paste the json source i get fro...

found this but this example is jquery
 
10:29 PM
@bigchungus you should* be able to but I'm more familiar with React and not mustache
 

« first day (3751 days earlier)      last day (1180 days later) »