I am trying to pass data from an API to my website.
My directory:
project > server.js | public
public > index.html | styles.css
My code, a part of it, in server.js:
var link, txt; // I want to export these 2 variables to the website
fetch(`url`)
.then(res => res.json())
.then(body => {
console.log(body); //receiving a json body and assigning data to both variables
link = body.path;
txt = body.path;
})
.catch(error => {
console.log(error);
});
I did not find any way to manipulate this into index.html, any good advice? is this possible through React and Node?
In App.js from React, I wanted something like:
<p>{link} or {text}</p>
I'm new in web dev, any help you can give would be greatly appreciated.