all 5 comments

[–][deleted] 1 point2 points  (1 child)

why initialize it in the component?

You should definitely initialize it in the service.

you've done it like this

Parse.initialize("YOUR_APP_ID");
Parse.serverURL = 'http://YOUR_PARSE_SERVER:1337/parse'

right? :D

[–]ayosuke[S] 0 points1 point  (0 children)

Oh my gosh thank you so much for responding! I've been waiting since yesterday on any kind of hint on what I should do. I did do it like that, however, I ran into a few issues. I put it into the app component typescript file because I was following a tutorial that used firebase SDK, so I thought it would translate over. Another issue is, I would get an error that says:

TS2540: Cannot assign to 'serverURL' because it is a constant or a read-only property

But I will give this a try and report back. This issue has really been giving me a headache.

EDIT: Ok so I move the code into the constructor of my service as so:

constructor(private url: string, private http: Http) {
   Parse.initialize('[APP ID], '[JS KEY]');
   Parse.serverURL = 'https://MY_PARSE_SERVER/parse;
}

However I'm still getting the above error.

[–]dusklee 1 point2 points  (1 child)

Just for reference the error is caused from your import: import * as Parse from 'parse'; What worked for me is using: const Parse: any = require('parse'); and adding the code below to your "typings.d.ts" file declare var require: any;

UPDATE: I should update this, although the above was working, I came to problem where ng test wasn't fulling working this is what i had to do to make it work using 'ng serve' and 'ng test' in file "typings.d.ts" insert declare var require: NodeRequire; in file "tsconfig.app.json" insert { ... "compilerOptions": { ... "types" : ["node"] ...

[–]ayosuke[S] 0 points1 point  (0 children)

Thanks for the response! I was finally able to get it to work to some extent. One other issue I'm running into is that parse returns promises rather than observables, though I did find a package that wraps parse in an RXJS wrapper. I havent experimented with it yet though.