My API GET request is working in Postman, but not in React.JS / the browser.
This is the code I tried simply copied it from postman
useEffect(() => {
const myHeaders = new Headers();
myHeaders.append("Amelia", "XldbLuwlIl9rZ4BdGBRlowmkm21e0Bfy9eEzr6OKMM9D");
const requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow",
};
fetch(
"https://staging.terminister.de/wp-admin/admin-ajax.php?action=wpamelia_api&call=/api/v1/appointments",
requestOptions
)
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.error(error));
}, []);
}, []);
This is postman’s screenshot enter image description here
Anyone know how to resolve this.
New contributor
Muhammad Muzammal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.