I’m having trouble executing a AJAX call to a controller that belongs to Odoo.sh, I’m testing from my localhost.
try {
const response = await fetch(`${BASE_URL}/check_available_venues`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
from_date: start,
to_date: end,
booking_individuals_total
})
});
// Log the full response for debugging
console.log('Response status:', response.status);
console.log('Response headers:', Object.fromEntries(response.headers.entries()));
const responseText = await response.text(); // Get text before potentially parsing as JSON
console.log('Response body:', responseText);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}, body: ${responseText}`);
}
const data = JSON.parse(responseText);
// Rest of your existing code...
} catch (error) {
console.error('Venue check error details:', {
message: error.message,
stack: error.stack
});
this._toastMessage(`Failed to check available venues: ${error.message}`, 'error');
noNextStep = true;
}
This is the controller I’m trying to access:
@http.route("/check_available_venues", type='json', auth="none", methods=['POST', 'GET'], website=True, csrf=False,
cors='*')
def check_available_venues(self, from_date, to_date, booking_individuals_total):
While this is the error I’m getting: