Hi there,
So I have created a new CRA app, created a netlify.toml file with build settings in
[build]
command = “yarn build”
functions = “functions”
publish = “build”
and put my functions in a functions folder in the root. I am then attempting to call my function like this:
function handleClick(api) {
console.log("api", api);
fetch("/.netlify/functions/" + api)
.then(response => response.json())
.then(json => console.log("json", json))
.catch(err => console.log("err", err));
}
// ...
<button onClick={() => handleClick("hello")}>Button 1</button>
but am getting the error:
App.js:7 GET http://localhost:8888/.netlify/functions/hello 404 (Not Found)
handleClick @ App.js:7
onClick @ App.js:29
/…
App.js:7 err SyntaxError: Unexpected token F in JSON at position 0
I have not deployed the site to netlify as yet but my understanding was that when I run netlify dev, this would take care of the creation of a .netlify/functions folder (which it has not). From my understanding this mocks up the serverless setup of netlify locally. Is this correct?