git cloneyarn install && yarn watch:hot- open browser and access:
http://localhost:3000/laksa/isConnected - or you can
curlin your bash command
$bash curl http://localhost:3000/laksa/isConnected
true #if return ture, your local node server is connected to Zilliqaor like this
$bash curl curl http://localhost:3000/laksa/getBalance\?address\=9bfec715a6bd658fcb62b0f8cc9bfa2ade71434a
{"balance":0,"nonce":0} # return the balance of requested addressThere are 2 places you need to edit.
/src/services/restful/laksa.js/src/router/restful.js
If you are familiar with laksa, you can see laksa.js is pretty simple
export const isConnected = async () => {
const result = await laksa.isConnected()
return result
}
export const getBalance = async req => {
const { query } = req
const result = await laksa.zil.getBalance({ address: query.address })
return result
}
// try to add this
export const getNetworkId = async () => {
const result = await laksa.zil.getNetworkId()
return result
}Then , in the resful.js
const routerTable = [
{
method: 'get',
name: '/isConnected',
exec: laksa.isConnected
},
{
method: 'get',
name: '/getBalance',
exec: laksa.getBalance
},
// add this
{
method: 'get',
name: '/getNetworkId',
exec: laksa.getNetworkId
}
]Save both files, and the server will build rebuild itself
then you can see if the restful API works:
$bash curl http://localhost:3000/laksa/getNetworkId
TestNet # if the api works, it will return the result