I read many people asking for this problem so now I try to fix their issue once and for all.
99% of the times this error is caused by the wrong router address of Pancakeswap.
If you are on testnet use this: 0xD99D1c33F9fC3444f8101754aBC46c52416550D1
If you are on mainnet use this: 0x10ED43C718714eb63d5aA57B78B54704E256024E
If after changing it you still get the error, clean cookies and cache.
Are you still getting this error? Well open a topic and share your code and your problem.
Community will help