Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.get("/users", (req, res) => {
- console.log("a get request");
- var tryFetch = { myString: "I am working fetch" };
- res.json(tryFetch);
- });
- class Example extends React.Component {
- async componentDidMount() {
- console.log("mounting...");
- const response = await fetch("/users");
- console.log(response, "res");
- const responseJson = await response.json();
- console.log(responseJson, "this is the data....");
- }
- app.get("/users", (req, res) => {
- console.log("a get request");
- var getData = await fetch("https://jsonplaceholder.typicode.com/users");
- var response = await getData.json();
- console.log(response, "the response");
- res.send(json);
- });
Add Comment
Please, Sign In to add comment