diff --git a/src/axios.ts b/src/axios.ts new file mode 100644 index 0000000..5bd2328 --- /dev/null +++ b/src/axios.ts @@ -0,0 +1,24 @@ +import axios from 'axios' +import JSONbig from 'json-big' + +// Defines the API instance in Axios with special handling for big integers. +const axiosInstance = axios.create({ + baseURL: import.meta.env.VITE_API_URL, + timeout: 5000, + transformResponse: [ + function transform(data) { + // Replacing the default transformResponse in axios because this uses JSON.parse and causes problems + // with precision of big numbers. + if (typeof data === 'string') { + try { + data = JSONbig.parse(data) + } catch (e) { + /* Ignore */ + } + } + return data + } + ] +}) + +export default axiosInstance diff --git a/src/views/Search.vue b/src/views/Search.vue index d6acc8c..2e43edb 100644 --- a/src/views/Search.vue +++ b/src/views/Search.vue @@ -80,17 +80,18 @@ - diff --git a/src/views/Target.vue b/src/views/Target.vue index 1b4ca73..d8f471c 100644 --- a/src/views/Target.vue +++ b/src/views/Target.vue @@ -96,17 +96,17 @@