0

so I am new to netlify. I keep getting a 404 error every time I make a request. This is react, and for the JS code:

await fetch('./.netlify/functions/create-payment-intent.js', {
                    method: 'post',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify({ message: "test"}),
                }).then((res) => {
                    return res.json();
                });

Terminal:

Request from ::1: POST /.netlify/functions/create-payment-intent.js
Response with status 404 in 3 ms

In the debugger:

POST http://localhost:8888/.netlify/functions/example.js 404 (Not Found)

Please how do I fix this? Thanks.

1 Answer 1

-1

What I know about fetch function is that it takes 'URL' as an parameter not a file, your fetch code be like

fetch('https://some-api-call') basically Fetch's basic function is to work with API. For the details you may check out this link : https://www.javascripttutorial.net/javascript-fetch-api/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.