Calling a netlify function from another site

I have uploaded a js function to the /functions folder of my GitHub pages site:

const functionA = () => {
	console.log('HI EVERYONE!!');
	var rng_nums = new Uint32Array(2);
	if (window.crypto && window.crypto.getRandomValues)
		window.crypto.getRandomValues(rng_nums);
	// Chrome, Opera, Firefox
	else if (window.msCrypto && window.msCrypto.getRandomValues)
		window.msCrypto.getRandomValues(rng_nums);
	// IE
	else
		rng_nums = [
			Math.floor(Math.random() * 4294967295),
			Math.floor(Math.random() * 4294967295),
		]; // All outdated browsers
	return (rng_nums[0] >>> 5) * 67108864.0 + (rng_nums[1] >>> 6);
};

I have set up functions in my Netlify settings and it says 1 Lambda function actively running in production .

When I try and call it from a locally run create-react-app for testing, I get a error 502.

<button
	onClick={() => {
		const cors = `https://cors-anywhere.herokuapp.com/`;
		axios
			.get(
				`${cors}https://rickgove.netlify.app/.netlify/functions/functionA`
			)
			.then(res => {
				console.log('Success');
				console.log(res);
			})
			.catch(err => {
				console.log('Error');
				console.log(err);
			});
	}}
>
	Generate Random on Server
</button>

What am I doing wrong?

Hey there,
You can see your function errors here when you invoke the function: https://app.netlify.com/sites/rickgove/functions/functionA

When I hit the function endpoint, this is what I see in your logs:

1:04:31 PM: 2021-01-29T21:04:31.893Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.HandlerNotFound","errorMessage":"functionA.handler is undefined or not exported","stack":["Runtime.HandlerNotFound: functionA.handler is undefined or not exported","    at Object.module.exports.load (/var/runtime/UserFunction.js:144:11)","    at Object.<anonymous> (/var/runtime/index.js:43:30)","    at Module._compile (internal/modules/cjs/loader.js:999:30)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)","    at Module.load (internal/modules/cjs/loader.js:863:32)","    at Function.Module._load (internal/modules/cjs/loader.js:708:14)","    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)","    at internal/main/run_main_module.js:17:47"]}

Seems like your function is missing the handler described in our docs here:

Let us know if that helps or if there are any other questions!