mrowlsss @mrowlsss

what the fuck

mrowlsss @mrowlsss

I’m still working on wasteof.money for snap(.berkeley), but because I know how to use the wasteof api, I have came to the realization that I now have to create a mod with custom blocks (which i am very skilled at)

Nov 11, 2023, 1:21 PM
3
Nov 11, 2023, 2:23 PM
24
View all Parent

comments

Highlighted comment
const token = await (await fetch(...)).text;

And the function it's wrapped in has to be async, e.g.

// my favorite
const func = async () => {}
// or
const func = async function() {}
// or
async function func() {}

i tried

            const token = await (await fetch("https://api.wasteof.money/session", requestOptions).text;
     		alert(token);

and it isnt working, am i doing something wrong?

The brackets are unmatched, but apart from that, that should work. What's the error you're getting?

i am not getting any console error, nor the test alert i have put in, which is making me think previous js code is making it not work. here is my entire html doc, can you tell me what’s wrong?

<!doctype HTML>

<head>

</head>

<html>

<body>

<script src="https://twemoji.maxcdn.com/v/latest/twemoji.min.js" crossorigin="anonymous"></script>

<script>

window.onload = function() {

// Parses the document body and

// inserts <img> tags in place of Unicode Emojis

twemoji.parse(document.body, {

folder: 'svg',

ext: '.svg'

} // This is to specify to Twemoji to use SVGs and not PNGs

);

}

</script>

<style>

img.emoji {

width: 1.5em;

pointer-events: none;

}

</style>

<script>

var myHeaders = new Headers();

myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({

"username": "mrowlsss",

"password": "pass123donthackme"

});

var requestOptions = {

method: 'POST',

headers: myHeaders,

body: raw,

redirect: 'follow'

};

alert("a");

const token = await (await fetch("https://api.wasteof.money/session", requestOptions)).text;

alert(token);

</script>

</body>

</html>

You're not getting any errors at all? That's strange. I'd suggest removing the window.onload thing (as the script is at the bottom of the page anyways). Does that do anything?

actually, better and easier option, can you just give me code that will alert the response of the fetch?