Commit a656c773 authored by chenqikuai's avatar chenqikuai

fix

parent 76706204
...@@ -43,12 +43,9 @@ export default Vue.extend({ ...@@ -43,12 +43,9 @@ export default Vue.extend({
this.fetchLatestTxListData(); this.fetchLatestTxListData();
getNodeNum().then((res) => { getNodeNum().then((res) => {
if (res.error === null) { if (res.error === null) {
this.nodeNum = (res.result.countries || []).reduce( this.nodeNum = (res.result.countries || []).reduce((prev, cur) => {
(prev: number, cur: { country: string; value: number }) => { return prev + cur.value;
return prev + cur.value; }, 0);
},
0
);
} }
}); });
......
import { axios } from "."; import { axios, iJrpcRet } from ".";
const scanApi = "/setScan"; const scanApi = "/setScan";
export function getNodeNum() { export function getNodeNum(): Promise<
iJrpcRet<{
countries: {
country: string;
value: number;
}[];
}>
> {
return axios(scanApi, { return axios(scanApi, {
method: "post", method: "post",
params: { params: {
......
...@@ -15,3 +15,9 @@ export function axios( ...@@ -15,3 +15,9 @@ export function axios(
return ret.json(); return ret.json();
}); });
} }
export interface iJrpcRet<T> {
id: number;
error: null | string;
result: T;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment