How to update SteemJS apps to use the new endpoint (it will not work otherwise!!) 如何修復由於節點未更新而無法執行的SteemJS 的程式

in #busy6 years ago (edited)

steemjs fix.jpg

A while ago, I found out through @oflyhigh that the endpoint steemd.steemit.com is retiring. I didn't think that it effected me, because for SteemJS I use the latest CDN https://cdn.steemjs.com/lib/latest/steem.min.js, and I thought it will automatically be updated with the latest endpoint.

大家好, 在幾天前,O哥通知大家steemd.steemit.com結點将被关闭,而我還天真的想不會影響到我,因為我用的是SteemJS,而SteemJS的腳本則是從內容分發網路的https://cdn.steemjs.com/lib/latest/steem.min.js 導入,所以我以為這個自動更新的腳本會連到最新的節點。

Unfortunatley this is not the case at the moment. The change to the new endpoint has not been made in script on the CDN. You will have to make the change manually in your SteemJS app.

但並不是這麼回事。在內容分發網路上的腳本還沒有更新。你必須自己更改你的SteemJS app.

Using the SteemJS posting example for posting an article on the Steem Developer's portal: https://developers.steem.io/#quickstartexample

用這個Steem開發者網站上的發布文章腳本當範例:https://developers.steem.io/#quickstartexample

This is the original code inside the post article function:

這是原本在發布文章的函數內的代碼:

function postArticle()
{
  steem.broadcast.comment(
    document.getElementById('postingKey').value, // posting wif
    '', // author, leave blank for new post
    'steemtest', // first tag
    document.getElementById('username').value, // username
    'name-of-my-test-article-post', // permlink
    document.getElementById('title').value, // Title
    document.getElementById('article').value, // Body of post
    // json metadata (additional tags, app name, etc)
    { tags: ['secondtag'], app: 'steemjs-test!' },
    function (err, result) {
      if (err)
        alert('Failure! ' + err);
      else
        alert('Success!');
    }
  );
}   


Inside the postArticle() function, to update the endpoint URL to the new http://api.steemit.com, please add this line of code.

在postArticle()的函數內,把節點網址更新到https://api.steemit.com,請加這一行代碼.

steem.api.setOptions({ url: 'https://api.steemit.com'});


So now the start of the posting function looks like this:

所以這個函數中第一段變成這樣:

function postArticle()
{
    steem.api.setOptions({ url: 'https://api.steemit.com'});
  steem.broadcast.comment(
    document.getElementById('postingKey').value, // posting wif


I hope this tutorial helps you to fix your SteemJS App.

希望能幫助到各位修好你的SteemJS app。

Sort:  

恭喜你!您的这篇文章入选 @justyy 今日榜单 【优秀被错过的文章】, 请继续努力!若您不喜欢,请回复 STOP,谢谢。

Congratulations! This post has been selected by @justyy as today's 【Good Posts You May Miss】, Steem On! Reply STOP if don't want to see this. Thanks.

Coin Marketplace

STEEM 0.20
TRX 0.12
JST 0.029
BTC 61358.50
ETH 3378.70
USDT 1.00
SBD 2.52