export default function GetContent() {
const GetData = () => {
return fetch('/scrap', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: 'Ромашка',
type: 'ul'
})
}).then(data => data.json());
};
return (
<div>
<GetData />
</div>
)
}
import React, { useEffect } from 'react';
export default function GetContent() {
const GetData = () => {
...
};
useEffect(() => {
GetData().then(res => console.log(res));
}, []);
return (
<div>
</div>
)
}