@claude I have this example code usage:
try {
const { data, error: functionError } = await base44.functions.invoke('testApiKey');
console.log(functionError);
if (functionError || (data && data.error)) {
throw new Error(functionError?.message || data.error);
}
setApiKeyStatus(data);
} catch (err) {
console.log('this was an error', err);
setError(err.message);
} finally {
and a backend function:
Deno.serve(async (req) => {
try {
throw new Error('my life');
} catch (error) {
return new Response(JSON.stringify({ error: error.message }), {
status: 500,
headers: { "Content-Type": "application/json" },
});
}
});
and instead of returning the error in functionError, it's going to the catch clause.
and this is what is printed
[pages/HelloWorld.js] this was an error
AxiosError {message: 'Request failed with status code 500', name: 'AxiosError', code: 'ERR_BAD_RESPONSE', config: {…}, request: XMLHttpRequest, …}
code
:
"ERR_BAD_RESPONSE"
config
:
{transitional: {…}, adapter: Array(3), transformRequest: Array(1), transformResponse: Array(1), timeout: 0, …}
message
:
"Request failed with status code 500"
name
:
"AxiosError"
let's fix this so that it returns the error as part of the function invokation result, and add a test to verify it
@claude I have this example code usage:
and a backend function:
and instead of returning the error in
functionError, it's going to the catch clause.and this is what is printed
let's fix this so that it returns the error as part of the function invokation result, and add a test to verify it