Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSR Not working #32

Closed
oknoorap opened this issue Jun 26, 2019 · 5 comments
Closed

SSR Not working #32

oknoorap opened this issue Jun 26, 2019 · 5 comments

Comments

@oknoorap
Copy link

oknoorap commented Jun 26, 2019

I'm using version 0.1.68 but nothing is working. This is my codes:

import React from "react";
import useFetch from "use-http";

export default () => {
  const stories = useFetch(
    "https://hacker-news.firebaseio.com/v0/topstories.json",
    {
      onMount: true
    }
  );

  if (stories.error) return "Error";
  if (stories.loading) return "Loading";

  return <pre>{JSON.stringify(stories.data, null, 2)}</pre>;
};
@alex-cory
Copy link
Collaborator

What is the error?

@oknoorap
Copy link
Author

Please check nextjs example on the codesandbox, it also doesn't works

@alex-cory
Copy link
Collaborator

Everything should be working. Please use v0.1.73. See codesandbox

@khusamov
Copy link

@alex-cory Your example is not similar to the example of the author of the question. You have a file download by clicking. That is, client-side rendering. And server-side rendering is required.

@khusamov
Copy link

khusamov commented Jan 26, 2022

This example differs from the example presented on the use-http website

export default () => {
  const stories = useFetch("https://hacker-news.firebaseio.com/v0/topstories.json");
  if (stories.error) return "Error";
  if (stories.loading) return "Loading";
  return <pre>{JSON.stringify(stories.data, null, 2)}</pre>;
};

In theory, a request to the hacker-news site should occur on the server. But I checked - this does not happen. The request is sent alas on the client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants