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/lib": "^0.1.5",
|
||||
"@extollo/util": "^0.3.3",
|
||||
"@types/node-fetch": "^2.5.10",
|
||||
"axios": "^0.21.1",
|
||||
"bcrypt": "^5.0.1",
|
||||
"copyfiles": "^2.4.1",
|
||||
"firebase-admin": "^9.6.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
"openpgp": "^5.0.0-1",
|
||||
"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 * as openpgp from "openpgp"
|
||||
import * as crypto from "crypto"
|
||||
import axios from "axios"
|
||||
import fetch from "node-fetch"
|
||||
import {collect, uuid_v4} from "@extollo/util"
|
||||
import {ExposureResourceItem} from "../rtdb/ExposureResource"
|
||||
|
||||
@ -224,7 +224,7 @@ export class Blockchain extends Unit {
|
||||
*/
|
||||
public async getPeerSubmit(peer: Peer): Promise<Block[] | undefined> {
|
||||
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
|
||||
if ( Array.isArray(blocks) && blocks.every(block => {
|
||||
return isBlockResourceItem(block)
|
||||
@ -249,13 +249,14 @@ export class Blockchain extends Unit {
|
||||
this.peers.push(peer)
|
||||
|
||||
try {
|
||||
await axios.post(`${peer.host}api/v1/peer`, {
|
||||
host: this.getBaseURL(),
|
||||
}, {
|
||||
await fetch(`${peer.host}api/v1/peer`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
host: this.getBaseURL(),
|
||||
}),
|
||||
headers: {
|
||||
[header]: this.getPeerToken(),
|
||||
'content-type': 'application/json',
|
||||
}
|
||||
},
|
||||
})
|
||||
} catch (e) {
|
||||
this.logging.error(e)
|
||||
|
Loading…
Reference in New Issue
Block a user