I am obviously missing something here but I do not know what it is. I have built an API that I have sitting on a tomcat server that I am trying to access using fetch from backend code. I used the Corvid: Accessing Third-Party Services with the Fetch API as a reference for how the fetch request should be done however I get a [“WebMethod request timed-out after 14 seconds… Did you forget to resolve a promise?”] . When I run the exact same code on front end, it makes the request perfectly fine and updates my third-party resource as expected
Below is the code I have sitting on the backend. I have omitted the URL and some other data in the POST body:
export function sendRequest() {
let url = "https://www.some.com/url";
return fetch(url, {
method: 'post',
mode: 'no-cors',
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({"token": "someToken", "secret": "someSecret", "programID": "someID", "body": "someAES"})
})
.then(response => console.log(response.status))
}
This is the code I have sitting on the frontend:
export function exportPart(event) {
console.log("Sending request")
process.sendRequest()
.then(result => {console.log("It worked bruh!")})
}
I have also tried both the backend and frontend using a .catch() after the .then() but I then just receive the .catch() response.
Any ideas as to why this is not working or what I am missing?