← Back to team overview

dhis2-devs team mailing list archive

Re: Fwd: Getting dataStore from dhis server

 

Hey,

Not sure if you still need help with this but it looks like Angular2?

I believe that this.http.get returns an Observable, so you'll need to
subscribe to it. You might want to have a look at [1]

[1]
https://angular.io/docs/ts/latest/guide/server-communication.html#!#the-herolistcomponent-class

On Mon, Nov 14, 2016 at 4:35 PM, Halvdan Hoem Grelland <halvdan@xxxxxxxxx>
wrote:

> Also, for future reference <http://stackoverflow.com/help/mcve>
>
>
>
> On Mon, Nov 14, 2016 at 3:08 PM, Stian Sandvold <stian@xxxxxxxxx> wrote:
>
>> 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
>>>
>>>
>> _______________________________________________
>> 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
>>
>>
>
>
> --
> Halvdan Hoem Grelland
> Software developer, DHIS 2
> University of Oslo
> http://www.dhis2.org <https://www.dhis2.org/>
>
>
> _______________________________________________
> 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
>
>


-- 
Regards,


Mark Polak
Software developer, DHIS 2
University of Oslo
http://www.dhis2.org <https://www.dhis2.org/>
mark@xxxxxxxxx

References