mirror of
https://github.com/hackku21/loc-chain-backend.git
synced 2024-10-27 20:34:03 +00:00
Replace axios with node-fetch
This commit is contained in:
parent
327d1a6ebd
commit
7fcde77bbe
@ -12,10 +12,12 @@
|
|||||||
"@extollo/di": "^0.4.5",
|
"@extollo/di": "^0.4.5",
|
||||||
"@extollo/lib": "^0.1.5",
|
"@extollo/lib": "^0.1.5",
|
||||||
"@extollo/util": "^0.3.3",
|
"@extollo/util": "^0.3.3",
|
||||||
|
"@types/node-fetch": "^2.5.10",
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
"bcrypt": "^5.0.1",
|
"bcrypt": "^5.0.1",
|
||||||
"copyfiles": "^2.4.1",
|
"copyfiles": "^2.4.1",
|
||||||
"firebase-admin": "^9.6.0",
|
"firebase-admin": "^9.6.0",
|
||||||
|
"node-fetch": "^2.6.1",
|
||||||
"openpgp": "^5.0.0-1",
|
"openpgp": "^5.0.0-1",
|
||||||
"typescript": "^4.2.4"
|
"typescript": "^4.2.4"
|
||||||
},
|
},
|
||||||
|
1633
pnpm-lock.yaml
1633
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -10,7 +10,7 @@ import {
|
|||||||
import {TransactionResourceItem} from "../rtdb/TransactionResource"
|
import {TransactionResourceItem} from "../rtdb/TransactionResource"
|
||||||
import * as openpgp from "openpgp"
|
import * as openpgp from "openpgp"
|
||||||
import * as crypto from "crypto"
|
import * as crypto from "crypto"
|
||||||
import axios from "axios"
|
import fetch from "node-fetch"
|
||||||
import {collect, uuid_v4} from "@extollo/util"
|
import {collect, uuid_v4} from "@extollo/util"
|
||||||
import {ExposureResourceItem} from "../rtdb/ExposureResource"
|
import {ExposureResourceItem} from "../rtdb/ExposureResource"
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ export class Blockchain extends Unit {
|
|||||||
*/
|
*/
|
||||||
public async getPeerSubmit(peer: Peer): Promise<Block[] | undefined> {
|
public async getPeerSubmit(peer: Peer): Promise<Block[] | undefined> {
|
||||||
try {
|
try {
|
||||||
const result = await axios.get(`${peer.host}api/v1/chain/submit`)
|
const result = await fetch(`${peer.host}api/v1/chain/submit`).then(res => res.json())
|
||||||
const blocks: unknown = result.data?.data?.records
|
const blocks: unknown = result.data?.data?.records
|
||||||
if ( Array.isArray(blocks) && blocks.every(block => {
|
if ( Array.isArray(blocks) && blocks.every(block => {
|
||||||
return isBlockResourceItem(block)
|
return isBlockResourceItem(block)
|
||||||
@ -249,13 +249,14 @@ export class Blockchain extends Unit {
|
|||||||
this.peers.push(peer)
|
this.peers.push(peer)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await axios.post(`${peer.host}api/v1/peer`, {
|
await fetch(`${peer.host}api/v1/peer`, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({
|
||||||
host: this.getBaseURL(),
|
host: this.getBaseURL(),
|
||||||
}, {
|
}),
|
||||||
headers: {
|
headers: {
|
||||||
[header]: this.getPeerToken(),
|
|
||||||
'content-type': 'application/json',
|
'content-type': 'application/json',
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logging.error(e)
|
this.logging.error(e)
|
||||||
|
Loading…
Reference in New Issue
Block a user