-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetMarketFeed.ts
52 lines (47 loc) · 1.05 KB
/
getMarketFeed.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import config from './config.json';
const marketUrl = `${config.BASE_URL}/MarketFeed`;
const requestList = [
{
Exch: 'N',
ExchType: 'D',
Symbol: 'BEL 25 Jan 2023',
Expiry: '20230125',
StrikePrice: '0',
OptionType: 'XX',
},
];
const marketPayLoad = {
head: {
appName: config.APP_NAME,
appVer: '1.0.0',
key: config.APP_USER_KEY,
osName: 'WEB',
requestCode: '5PMF',
userId: config.APP_USER_ID,
password: config.APP_PASSWORD,
},
body: {
Count: 1,
MarketFeedData: requestList,
ClientLoginType: 0,
LastRequestTime: `/Date(${0})/`,
RefreshRate: 'H',
},
};
try {
const res = await fetch(marketUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(marketPayLoad),
});
if (res.ok) {
const response = await res.json();
console.log('Market Feed response : ', response.body.Data);
} else {
console.error('Some error occured : ', await res.text());
}
} catch (error) {
console.error('Some error occured : ', error);
}