I have two AWS EC2 instance, one for JS web page and one for Django server.
Django server is in private subnet and JS in public subnet.
my JS fetch code is like below
fetch('http://10.0.136.201:8080/evaluation/get-price/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(formData)
})
.then(response => response.json())
.then(data => {
console.log('Success:', data);
document.getElementById('result').textContent = String(Math.round(Number(JSON.stringify(data['answer'])))) + "원";
})
.catch((error) => {
console.error('Error:', error);
alert('오류가 발생했습니다. 다시 시도해주세요.');
});
console.log(formData['volatility']);
console.log(formData['interestRate']);
console.log(formData['redemptionDates']);
and my curl command is this
curl -X POST -H "Content-Type: application/json" -d '{"key": "value"}' http://10.0.136.201:8080/evaluation/get-price/
I can see the curl request from Django server log and it return response successfully, but when I use fetch in JS, even there is no any log that JS requested.
Is there any problem with browser? I assume there is no problem with AWS security group, because curl command works well.
COM BOM is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.