getUserData.mjs file ```import fs from 'fs';
export default async (event, context) => {
const queryParams = event.queryStringParameters;
// if (!queryParams || !queryParams.number) {
// return new Response(JSON.stringify({ message: 'Number parameter is required' }), {
// status: 400,
// headers: {
// 'Content-Type': 'application/json'
// }
// });
// }
// const { number } = queryParams;
const number = queryParams.number;
// Construct the file path based on the number parameter
const filePath = `/.netlify/functions/getUserData_${number}.json`;
try {
// Check if the file exists
fs.accessSync(filePath, fs.constants.F_OK);
// File exists, read its contents
const userData = fs.readFileSync(filePath, 'utf8');
return new Response(userData, {
headers: {
'Content-Type': 'application/json'
}
});
} catch (error) {
// File doesn't exist
return new Response(JSON.stringify({ message: 'User not found' }), {
status: 404,
headers: {
'Content-Type': 'application/json'
}
});
}
};```
issues im getting with it is the first picture.
before i put // from line 6 to 14 it gave me **{“message”: “Number parameter is required” }** in /.netlify/functions/getUserData?number=dak
my getUserData_dak.json code is
{"number":"sleepy","ssn":"050102-1377","name":"Sleepy 1.8","expiry":"2025-04-22","imageUrl":"/assets/proFENI.png"}
which should be my info when logging with the code "dak" but its not since the issues im getting.