i'm new with react and api. i try to get an api with fetch from mongodb. the console.log is ok, but i bug to render it.
import React from 'react';
class Api extends React.Component {
componentDidMount() {
const apiUrl = 'https://us-east-1.aws.webhooks.mongodb-realm.com/api/client/v2.0/app/cv-xfzvw/service/cv/incoming_webhook/api?secret=cv';
fetch(apiUrl)
.then((response) => response.json())
.then((data) => console.log('This is your data', data));
}
render() {
return {data};
}
}
export default Api;
Does anyone know how how to return body ? Thank you for your help.
componentDidMount, when the data is available in the 2ndthen()method's callback function, update the state. 3. Render the data from the state in therender()method.