Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to initialize Parse and point to serverURL using Angular2

I am attempting to use a Parse server and am currently running into issues with initializing Parse in javascript and pointing to the correct serverURL. Curious if anyone else has had any luck doing this with Angular2 yet?

like image 494
joshsisley Avatar asked Sep 11 '25 20:09

joshsisley


1 Answers

For frameworks that use typescript (ex. angular 2, ionic 2 & 3),

To solve the typescript read-only error:

Typescript Error

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

Parse.serverURL = 'http://localhost:1337/parse';

Use (Parse as any) instead of Parse to set the value of serverUrl such as:

import * as Parse from 'parse';

Parse.initialize('appId', 'jsKey');  // use your appID & your js key
(Parse as any).serverURL = 'http://localhost:1337/parse'; // use your server url

This require parse and @types/parse to be installed:

npm install --save @types/parse parse 
like image 107
ahmedengu Avatar answered Sep 14 '25 11:09

ahmedengu