Fix spacing on ws commonjs api example

This commit is contained in:
hunicus 2022-09-13 07:14:03 -04:00
parent 0a645431ae
commit 19a86cbd59
No known key found for this signature in database
GPG Key ID: 24837C51B6D81FD9

View File

@ -17,27 +17,27 @@ export const wsApiDocsData = {
codeTemplate: { codeTemplate: {
curl: `/api/v1/ws`, curl: `/api/v1/ws`,
commonJS: ` commonJS: `
const { %{0}: { websocket } } = mempoolJS(); const { %{0}: { websocket } } = mempoolJS();
const ws = websocket.initClient({ const ws = websocket.initClient({
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'], options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
}); });
ws.addEventListener('message', function incoming({data}) { ws.addEventListener('message', function incoming({data}) {
const res = JSON.parse(data.toString()); const res = JSON.parse(data.toString());
if (res.block) { if (res.block) {
document.getElementById("result-blocks").textContent = JSON.stringify(res.block, undefined, 2); document.getElementById("result-blocks").textContent = JSON.stringify(res.block, undefined, 2);
} }
if (res.mempoolInfo) { if (res.mempoolInfo) {
document.getElementById("result-mempool-info").textContent = JSON.stringify(res.mempoolInfo, undefined, 2); document.getElementById("result-mempool-info").textContent = JSON.stringify(res.mempoolInfo, undefined, 2);
} }
if (res.transactions) { if (res.transactions) {
document.getElementById("result-transactions").textContent = JSON.stringify(res.transactions, undefined, 2); document.getElementById("result-transactions").textContent = JSON.stringify(res.transactions, undefined, 2);
} }
if (res["mempool-blocks"]) { if (res["mempool-blocks"]) {
document.getElementById("result-mempool-blocks").textContent = JSON.stringify(res["mempool-blocks"], undefined, 2); document.getElementById("result-mempool-blocks").textContent = JSON.stringify(res["mempool-blocks"], undefined, 2);
} }
}); });
`, `,
esModule: ` esModule: `
const { %{0}: { websocket } } = mempoolJS(); const { %{0}: { websocket } } = mempoolJS();