-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: added custom axios call to retreive image from api
- Loading branch information
Showing
7 changed files
with
60 additions
and
58 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import axios from 'axios'; | ||
import { OpenAPI } from '../generated'; | ||
|
||
export const getVariogramImage = async (imageId: string): Promise<string> => { | ||
const token = OpenAPI.TOKEN; // replace with your bearer token | ||
const base = OpenAPI.BASE; | ||
|
||
try { | ||
const response = await axios.get(`/api/images/variogram/${imageId}`, { | ||
headers: { Authorization: `Bearer ${token}` }, | ||
responseType: 'blob', // response type of blob to handle images | ||
baseURL: base, | ||
}); | ||
|
||
// create an object URL for the image blob and return it | ||
return URL.createObjectURL(response.data); | ||
} catch (error) { | ||
console.error(`Error fetching image: ${error}`); | ||
throw error; // re-throw the error so it can be handled by the caller | ||
} | ||
}; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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