mrowlsss @mrowlsss

@wully i think ur api docs for wasteof 2 regarding getting token is outdated

Nov 4, 2023, 6:07 AM
19
View all Parent

comments

Highlighted comment

needs to be json not form-data

how the fuck u do that

like whats the json format

it needs to be in an object (you’re missing {} around it)

also the Content-Type header must be set to application/json (libraries that allow JSON POST data usually do this automatically but a request maker like that or curl usually don’t)

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "username": "mrowlsss",
  "password": "password"
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("api.wasteof.money/session/", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

returns {}

i have no idea what’s going wrong

for me, if you don’t send json data you get {"error":"must send json data"}, and once i fixed it it said {"error":"incorrect username or password"} (obviously). cc @jeffalo since wuilly’s on his break — do you know what’s wrong here?

works fine for me. maybe change it to be https://api.wasteof.money @mrowlsss? because without the https:// it will be a relative request and idk how that works in nodejs, but in the browser it makes a request to the current domain slash that

See more replies