Created
April 29, 2022 17:44
-
-
Save zekhoi/278128f4f9ef899373633492ef10c62d to your computer and use it in GitHub Desktop.
Proxy Using AllOrigins Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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