Solution
const onSearch = () => {
navigate(`/search?q=${searchedText}`);
fetch('/ML/search',{
method: 'POST',
body: JSON.stringify({
content:searchedText
})
}).then(response => response.json()
.then(data => ({ data, response })))
.then(({ data, response }) => {
console.log(data)
})
};