Skip to content

Instantly share code, notes, and snippets.

@zekhoi
Created April 29, 2022 17:44
Show Gist options
  • Save zekhoi/278128f4f9ef899373633492ef10c62d to your computer and use it in GitHub Desktop.
Save zekhoi/278128f4f9ef899373633492ef10c62d to your computer and use it in GitHub Desktop.
Proxy Using AllOrigins Example
import axios from "axios";
const axiosInstance = axios.create({
baseURL: "https://api.allorigins.win/get?url=",
});
const fetchAPI = async ({ categoryId }: BookAPI) => {
try {
const response = await axiosInstance.get("https://jsonplaceholder.typicode.com/posts");
// Maka requestnya dikirim ke https://api.allorigins.win/get?url=https://jsonplaceholder.typicode.com/posts
return response.data;
} catch (error) {
console.log(error);
}
};
export { fetchAPI };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment