So if you download the Parse platform example nodejs example which can be found here https://github.com/parse-community/parse-server-example , you will notice that Parse does not get imported/required at all. I know they do not explicitly call Parse in the project, but that is after all the way you do queries, and even initialize the project.
So My problem is, I have a typescript setup but if I import Parse like this
import * as Parse from 'parse/node';
Whenever I do a query it throws me this error.
ParseError: XMLHttpRequest failed: {"UNSENT":0,"OPENED":1,"HEADERS_RECEIVED":2,"LOADING":3,"DONE":4,"readyState":4,"responseText":"","responseXML":"","status":410,"statusText":null,"withCredentials":false}
I am using these versions in my package.json:
"parse": "^2.7.1",
"parse-server": "^2.3.3",
I have tried to import Parse the old fashioned way with var Parse = require('parse/node'), Imported the browser version import * as Parse from 'parse'; which just tells me that localstorage has not been set, obviously because its node not Browser.
I tried running the example project by doing a simple query with and without the import and get consistent results, So it does not seem to be a typescript issue.
I tried multiple versions of Parse as well, even version 1.8 which they use in the example project gets the same results.
import express from "express";
import * as PS from 'parse-server';
import path from "path";
import {config} from 'dotenv';
import bodyParser from "body-parser";
import cors from 'cors';
import * as Parse from 'parse/node';
config({path:'./env/dev_remote.env'});
const app = express();
const port = process.env.PORT || 1337;
const ParseServer = PS.ParseServer;
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
app.use(cors());
var api = new ParseServer({
databaseURI: process.env.dbUrl + '/' + process.env.dbName,
appId:'totalProjectServer',
masterKey:'masterparse',
serverURL:'http://localhost:1337/parse'
});
app.use('/parse', api);
Parse.initialize('totalProjectServer');
app.get('/', (req, res) => {
let query = new Parse.Query('NodeExpense');
query.find().then((data)=>{
res.status(200).send(data);
})
.catch((err)=>{
res.status(500).send(err);
})
})
app.listen(port,()=>{
console.log(`Server running on ${port}`);
})
I just want to get my IntelliSense to work and typescript to stop complaining because I am not importing Parse. It just looks wrong if you use functions that are not being imported.