new TradingView.widget({
/* 为简单起见隐藏其他小部件选项 */
news_provider: function getNews(symbol, callback) {
callback({
title: 'This is the title!',
newsItems: [/* ... */]
})
}
});
const jsonNewsApiUrl = 'https://www.example.com';
new TradingView.widget({
/* 为简单起见隐藏其他小部件选项 */,
news_provider: function getNews(symbol, callback) {
fetch(jsonNewsApiUrl)
.then(res => res.json())
.then(json => {
callback({
newsItems: json,
});
});
}
});
const widget = new TradingView.widget({
/* widget options hidden for simplicity */
});
function someEventHandler() {
widget.news().then(newsApi => newsApi.refresh());
}