Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Starter Kit error - page not found

I created a new route from the react-starter-kit project and it does an async fetch of some data, then renders it, but a second later the page reloads with a message saying "Page not found - sorry but the page you're trying to view does not exist".

In the console I see - "Warning: Text content did not match. Server: "Balances" Client: "Page Not Found"

async function action() {

let bittrex = new ccxt.bittrex ({
    'apiKey': '',
    'secret': ''
})

try {

    // fetch account balance from the exchange
    let bittrexBalance = await bittrex.fetchBalance ()
    /**** commenting above and uncommenting this block stops it from happening.... 
    let bittrexBalance = {};
    bittrexBalance.info= [];
    let currency = {};
    currency.Currency = "BTC";
    currency.Value=999;
    // output the result
    bittrexBalance.info.push(currency);*/
    console.log ('balance', bittrexBalance)

    let balances = [];
    balances.push(bittrexBalance)
    return {
        title: "Balances",
        component: (
            <Layout>
                <Balances balances={balances} />
            </Layout>
        ),
    };


} catch (e) {
    console.log('SOME sort of error', e);
}

Does anyone have any idea what this could be?

Edit to add, I realise now that if I disable Javascript everything works perfectly...

It seems to be running through the universal router twice. The first time The second time it runs through the router it seems to have a params appears to have an object of {0: "/balances"}

That's the only clue I've found so far... I don't understand why it's reloading the page once it has already loaded...

The Page not found error is coming from it going through :

catch (e) the second time... I suspect something is happening inside the ccxt library but that the problem is actually that it is called a second time because the page is somehow reloaded...

like image 391
iKode Avatar asked Jan 19 '18 10:01

iKode


Video Answer


2 Answers

It seems you have to call await bittrex.loadProducts() before fetching your Balance.

Edit : Seems also that bittrex.loadProducts() has been renamed by bittrex.loadMarkets() More info in this issue on github

like image 79
Dyo Avatar answered Sep 23 '22 21:09

Dyo


Your server code reached exception, which turns into rejection of route, because action method returns undefined, so server will fall down through — next routes will not fit and finally it reaches the not found route.

like image 20
langpavel Avatar answered Sep 23 '22 21:09

langpavel