Skip to content

Commit 6467c9c

Browse files
committed
Updated the News Delivery example
1 parent fca83db commit 6467c9c

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

‎src/3.Delivery/3.2-Endpoint/endpoint_NewsHeadlines.ts‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
// Note: To configure settings for your environment, modify the session.config json file
99
// **********************************************************************************************************************
10-
import { Delivery, Session } from '@refinitiv-data/data';
10+
import { Delivery, News } from '@refinitiv-data/data';
1111
import { getSession } from '../../Common/session';
1212

1313
const session = getSession();
@@ -26,11 +26,20 @@ const session = getSession();
2626
};
2727

2828
const def = Delivery.EndpointRequest.Definition(param);
29-
const response = await def.getData(session);
30-
console.log('Received data:', JSON.stringify(response.data, null, ' '));
31-
32-
// console.log(response.data.data[0].storyId);
29+
const response = await def.getData(session) as any;
30+
console.log('Headlines received, getting stories');
3331

32+
const storyIds = response.data.data.map((story: any) => story.storyId);
33+
const stories = storyIds.map((storyId: any) => {
34+
const definition = News.Story.Definition({
35+
storyId,
36+
});
37+
return definition.getData(session);
38+
});
39+
40+
const result = await Promise.all(stories);
41+
console.log('Stories received:');
42+
console.log(result);
3443
}
3544
catch (err) {
3645
console.log(err);

0 commit comments

Comments
 (0)