Error in console

I proceeded according to the training video for making the exchange, but when I got the price from Moralis, I encountered this error

Can you also post:

  • The error in text format:
  • Related code (…/tokenprice…)
  • timestamp of the video you are working at

Also some related info: The error is related to CORS.
CORS is a security feature implemented by browsers to restrict web pages from making requests to a different domain than the one that served the web page.

In this case it seems that the Javascript client is trying to make a request with CORS when it is not needed, so some kind of manual disable may help.

Also It looks like you are trying to request /tokenPrice to localhost, which looks right. See examples of this type of code here: https://docs.moralis.io/web3-data-api/evm/reference/get-token-price



I received these two errors, one in the console and the other when running node index.js
I think it’s from your api, I’m sure I entered it correctly

Hi @taha1234

The Error message says invalid address provided. The reason could be the address that you passed to the API function is either null, undefined, or wrong.

Please try adding some console.log for logging the address value on the server for further debugging.

The error in the browser console should be resolved once the backend error is fixed.

Everything is correct, I should not install a package

Is it solved now?
Do you have any other questions?

I followed your instructions and was able to get the price from API and the console was displayed
Only here, I want to display the ratio of Dewars with these codes, but it shows the NaN

what are you returning from that endpoint?

I went completely according to your training video and when I wanted to show the ratio of two currencies in the second input, it shows the amount of NaN.

yes but what are you returning from that endpoint? it needs to return something. You can console.log(res.data) to see if you get anything in return

yes see it in console

if you get the results, then its a matter of how you display them inside your app


new error
According to this code, I wanted to run the approve function using 1inch, but it had a problem and could not communicate with 1inch.

[image]

Hi @taha1234

Can you share the error message of this failed request? You can find the error message in browser network tab.

The image only shows the error message of axios which is Request failed with status code 400 but this is not the error from the API.

If you can access the network tab from developer tools you can find the error response from the 1inch API

Yes, there is a problem with Axios, but how can I fix it?

That is not an error in axiso. It is an error from backend code. Axios shows same error message for any backend error. So you need to find the correct error message from backend logs or from network tab.