Skip to content

TypeError this.provider.sendAsync #334

@wilbarnes

Description

@wilbarnes

Hello,

I was working through the tutorial https://developer.dharma.io/tutorials/create

dharma-chain running on 8545

const { Dharma, Web3 } = require("@dharmaprotocol/dharma.js");
const BigNumber = require("bignumber.js");

const host = "http://localhost:8545";
const dharma = new Dharma(host);

async function loanreq() {

    const { LoanRequest } = Dharma.Types;

    const loanRequest = await LoanRequest.create(dharma, {
        principalAmount: new BigNumber(1),
        principalToken: "WETH",
        collateralAmount: new BigNumber(20),
        collateralToken: "REP",
        interestRate: new BigNumber(3),
        termDuration: new BigNumber(3),
        termUnit: "months",
        expiresInDuration: new BigNumber(1),
        expiresInUnit: "weeks"
    });
    console.log(loanRequest);
}

loanreq()

Output

(node:8362) UnhandledPromiseRejectionWarning: TypeError: this.provider.sendAsync is not a function
    at RequestManager.sendAsync (/xyz/xyz/xyz/projects/dharma/dharmajs/node_modules/@dharmaprotocol/dharma.js/dist/dharma.umd.js:88601:19)
    at Object.send (/xyz/xyz/xyz/projects/dharma/dharmajs/node_modules/@dharmaprotocol/dharma.js/dist/dharma.umd.js:14677:42)
    at /xyz/xyz/xyz/projects/dharma/dharmajs/node_modules/@dharmaprotocol/dharma.js/dist/dharma.umd.js:5610:10
    at new Promise (<anonymous>)
    at new F (/xyz/xyz/xyz/projects/dharma/dharmajs/node_modules/@dharmaprotocol/dharma.js/dist/dharma.umd.js:36181:28)
    at /xyz/xyz/xyz/projects/dharma/dharmajs/node_modules/@dharmaprotocol/dharma.js/dist/dharma.umd.js:5592:12
    at BlockchainAPI.<anonymous> (/xyz/xyz/xyz/projects/dharma/dharmajs/node_modules/@dharmaprotocol/dharma.js/dist/dharma.umd.js:301244:72)
    at step (/xyz/xyz/xyz/projects/dharma/dharmajs/node_modules/@dharmaprotocol/dharma.js/dist/dharma.umd.js:301081:23)
    at Object.next (/xyz/xyz/xyz/projects/dharma/dharmajs/node_modules/@dharmaprotocol/dharma.js/dist/dharma.umd.js:301062:53)
    at /xyz/xyz/xyz/projects/dharma/dharmajs/node_modules/@dharmaprotocol/dharma.js/dist/dharma.umd.js:301056:71
(node:8362) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:8362) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled wil terminate the Node.js process with a non-zero exit code.

Was simply trying to print the loanRequest

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions