← Back to team overview

dhis2-devs team mailing list archive

Re: Fwd: Getting dataStore from dhis server

 

Hi. Could you try JSON.stringify(AAAA) instead of to toString?

On 14 Nov 2016 3:05 p.m., "Knut Staring" <knutst@xxxxxxxxxx> wrote:

> Hi devs,
>
> Could you please respond to this?
>
> Thanks,
> Knut
>
> ---------- Forwarded message ----------
> From: <magnuswmolaug@xxxxxxxxx>
> Date: Mon, Nov 14, 2016 at 11:06 AM
> Subject: Getting dataStore from dhis server
> To: "knutst@xxxxxxxxxx" <knutst@xxxxxxxxxx>
>
>
>
> Whenever we try to get a json object containing all the dataStore items,
> it returns an empty object.
>
>
>
> This is the code which is run at pageload.
>
>
>
>
> loadObjectList(): *void *{
>
>
> console.log("BBBB" + *this*.appService.getNamespaces());
>
>
>
> }
>
>
>
>
>
> This method in the app.component.ts file references the getNamespaces
> function in the app.service.ts file
>
>
>
>
>
>
> *private *serverUrl = 'https://play.dhis2.org/test/api/dataStore';
>
> *private *headers = *new *Headers({'Content-Type': 'application/json'});
>
>
>
>
> getNamespaces(): *any*{
>
>
>
>
> *var *AAAA;
> AAAA = *this*.http.get(*this*.serverUrl, {headers: *this*.headers})
>     .map(res => res.json());
> console.log("AAAA: " + AAAA.toString());
> *return *AAAA;
>
>
>
> }
>
>
>
> This method tries to contact the dhis2.org/test server to get the
> dataStore object.
>
> I know that it exist, as the url ‘https://play.dhis2.org/test/a
> pi/dataStore’ gives
>
> ["METADATASTORE","social-media-video"]
>
>
>
> This tells me that I should at least get something, but I don’t.
>
>
>
> I also tried to add my client to the CORS whitelist, and tried different
> types of header, but nothing works.
>
>
>
> I constantly get the response
>
> app.service.ts:91                           AAAA: [object Object]
>
> app.component.ts:195                 BBBB[object Object]
>
>
>
> Hope you have an answer for this
>
>
>
> Regards, Magnus W. Molaug
>
>
>
> --
> Cheers,
> Knut Staring
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dhis2-devs
> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dhis2-devs
> More help   : https://help.launchpad.net/ListHelp
>
>

Follow ups

References