[SOLVED] React useOneInchSwap not working

this sounds like there is a different problem and not with the swap

one second let me show you something different the quote throws a different error as soon as i add the code

import { useOneInchQuote } from "react-moralis";

export default function Quote() {
  const { getQuote, data, isFetching, isLoading, error } = useOneInchQuote({
    chain: 'bsc', // The blockchain you want to use (eth/bsc/polygon)
    fromTokenAddress: '0x0da6ed8b13214ff28e9ca979dd37439e8a88f6c4', // The token you want to swap
    toTokenAddress: '0x6fd7c98458a943f469e1cf4ea85b173f5cd342f4', // The token you want to receive
    amount: 1000,
  });
  return (
     <div>
        {error && <>{JSON.stringify(error)}</>}
        <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
}

code

error

any ideas?

I’m not really expert in react, I found that in source code/documentation

you are using latest version of moralis and react-moralis?

I am i actually just uninstalled and reinstalled it, ill look around hopefully i get this figured out its kind of annoying

i figured out the issue i didnt have the plugin installed lol

2 Likes

Hi Wayne. I also have this same issue. How did you fix yours please? Did you install the plugin on react?

Nope, the pulgin is installed on the server rather.

Thanks Ayo for the update. I installed the plugin on the server but I’m still experiencing same issue, do you know the fix for this?

What’s the issue you got?

TypeError: Cannot read properties of undefined {reading “chain”}

If i add the chain, it show same error for address…

It is the same error the user who opened this issue had.

I am getting this same error, were you able to a
Solve this and how, thanks in advance

Hope you have the plugin installed on the server you’re using ?

@qudusayo, yeah of course, I used useOneInchTokens hook with no error,and there are very limited articles online about moralis, it’s like you have to solve your issues yourself.

This is the only thing that could help that I found online https://github.com/MoralisWeb3/react-moralis/issues/242

Which errors are you getting? Can you post your 1inch code?

@alex just mere calling the Useoneinchswap hook at line 39 gives the error

@hemarle were you able to solve this issue and how thanks

Thanks, I am getting that error as well with valid plugin install, and server restarted. It has already been reported on the react-moralis repo.

Which of the function failed, because it works fine for me.