import { Handler } from '@netlify/functions';
import { getXataClient } from '../../api/xata';
export const handler: Handler = async (event, context) => {
try {
const xata = getXataClient();
let allTodos = await xata.db['todo-list'].getAll();
return {
statusCode: 200,
body: JSON.stringify(allTodos),
};
} catch (error) {
console.error(error);
return {
statusCode: 500,
body: JSON.stringify(error),
};
}
};
#Netlify function works locally not in prod
1 messages · Page 1 of 1 (latest)
I am trying to create a todo app with vanilla js and xata with netlify serverless functions. when i try locally everything works fine but when deployed on netlify this function returns error.
Are you using environment variables locally?
And what is the error?
I am getting nothing it simply returns empty object
{}
yes
Your getting a 500 error response from the server you'll probably need to look at the log on netlify. Also double check and make sure you've correctly configured your Env vars inside netlify
they will be under site settings inside the netlify console
i did that already i am using one key for all scopes so that should not be an issue and variable name is also same