'am tyring to use this function getServerSideProps to connect to sanity backend but i get this browser error

./pages/index.js:24:2 Syntax error: 'import' and 'export' may only appear at the top level.

22 | ); 23 |

24 | export const getServerSideProps = async () => { | ^ 25 | const query = '*[_type == "product"]'; 26 | const products = await client.fetch(query); 27 |



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source