I am building a tool that makes a http request to various endpoints and returns the status code.
Using axios.get on an endpoint such as https://jsonplaceholder.typicode.com/users returns a 200 which is great, but when I try my tool out on facebook.com I get a request failed with status code 404', what am I doing wrong?
It seems the request url is http://localhost:5173/www.facebook.com, so my localhost is being added to the url?
import ky from "ky";
export const useFetchStatus = async (url: string) => {
const response = await ky.get(url);
console.log(response.status);
return response.status;
};
import { useEffect, useState } from "preact/hooks";
import { useFetchStatus } from "./hooks/hooks";
export const App = () => {
const [status, setStatus] = useState(0);
const url = "https://jsonplaceholder.typicode.com/users";
useEffect(() => {
const interval = setInterval(async () => {
const status = await useFetchStatus(url);
setStatus(status);
}, 1000);
return () => clearInterval(interval);
}, []);
return <>Status: {status}</>;
};