I set my base URL in axios.create() method and consume it another pages. but it added unnecessary '%E2%80%8B' in the URL. Is there any way to avoid this issue? This is my code block:
import axios from 'axios';
const apiVersion = 1;
export const baseURL = ('https://localhost:50001')
export default axios.create({
baseURL: baseURL,
});
export const urls = {
unit: {
get_all: `/api/v${apiVersion}/Unit/get-all-units`,
get_by_key: `api/v${apiVersion}ion}/Unit/get-unit`,
post: `/api/v${apiVersion}/Unit/save-unit`,
put: `/api/v${apiVersion}/Unit/update-unit`,
delete: `/api/v${apiVersion}/Unit/delete-unit`
}
}
This axios i intended to use my another component in this way:
const getAllUnits = async () => {
try {
await axios
.get(urls.unit.get_all)
.then(res => {
setRecords(res.data.data);
setIsLoaded(true)
})
} catch (e) {
console.log(e);
}
}
But it showing this error. Please help me out.enter image description here