"Expected key to be a string" error, everything looks fine to me?

Ok, I have no idea why this code just puts up this error!

My Code:

var express = require('express');
const store = require('data-store');
const mystore = new store({path: 'store.json'});
var app = express();
//app.use(express.static('public'));
app.use(express.json( { limit: "1mb"} ))
app.get("/", function (request, response) {
  response.send(mystore.get(request.query.data))
});
app.post("/updatedata", function (request, response) {
  const req = request
  console.log(req.body) // returns { type: 'main', data: [] }
  mystore.set(req.query.data) // Is where the error occurs
  response.send("OK")
});
app.get("/getdata", function (request, response) {
  const req = request
  console.log(req.body)
  mystore.get(req.query.data)
  response.send("OK")
});
var listener = app.listen(process.env.PORT, function () {
  console.log('Your app is listening on port ' + listener.address().port);
});

I am using roblox to post data and then get data from the datastore.

Check the docs for set in data-store. This kind of interface usually takes two arguments.

Thank you so much!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.