Reputation: 71
I'm trying to do a GET request on a Parse backend but i have a 403 response from the server. I tried to follow these instructions but i still have the issue.
Here's the configuration of my service :
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http';
import { environment } from 'src/environments/environment';
import * as Parse from 'parse';
Parse.initialize('MY APP ID', 'MY MASTER KEY ID'); // use your appID & your js key
(Parse as any).serverURL = 'https://MYURL/parse'; // use your server url
@Injectable({
providedIn: 'root'
})
export class BackofficeService {
constructor(private http: HttpClient) {}
public getStores(): Observable<any> {
return this.http.get(Parse.serverURL + '/classes/Stores');
}
I tried to add an empty paramater for the jskey (because i used master key instead of JS key) but it didn't work.
Parse.initialize('MY APP ID', '', 'MY MASTER KEY ID'); // use your appID & your js key
Upvotes: 1
Views: 3875
Reputation: 71
I resolved my issue by using what Julien gave me and modifying my service into a promise :
public getStores(): Promise <any> {
const Stores = Parse.Object.extend('Stores');
const query = new Parse.Query(Stores);
return query.find()
}
Upvotes: 1
Reputation: 5469
You are trying to use the Rest API of the Parse server, but you configure it with the SDK.
As you configure the SDK and you have it, I really recommend you to use it. Here is how to get all object of stores.
var Stores = Parse.Object.extend("Stores");
var query = new Parse.Query(Stores);
query.find().then(function(results) {
console.log(results);
});
Upvotes: 2