I'm going through a tutorial that makes use of axios for HTTP requests. I have set up an axios instance to look like this:
import axios from 'axios';
const axiosInstance = axios.create({
baseUrl: 'https://www.google.com/'
});
export default axiosInstance;
I have saved it in the root of my project in a file called AxiosOrders.js. When I import the file using import MyAxios from '../../AxiosOrders';
and do nothing else the console logs:
C:/DEV/Projects/learning-initiative/burger-builder/node_modules/process/browser.js
There are multiple modules with names that only differ in casing.
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
Use equal casing. Compare these module identifiers:
* C:\DEV\Projects\learning-initiative\burger-builder\node_modules\babel-loader\lib\index.js??ref--6-oneOf-2!C:\DEV\Projects\learning-initiative\burger-builder\node_modules\process\browser.js
Used by 2 module(s), i. e.
C:\DEV\Projects\learning-initiative\burger-builder\node_modules\babel-loader\lib\index.js??ref--6-oneOf-2!C:\DEV\Projects\learning-initiative\burger-builder\node_modules\react-error-overlay\lib\index.js
* C:\DEV\Projects\learning-initiative\burger-builder\node_modules\babel-loader\lib\index.js??ref--6-oneOf-2!C:\dev\Projects\learning-initiative\burger-builder\node_modules\process\browser.js
Used by 1 module(s), i. e.
C:\DEV\Projects\learning-initiative\burger-builder\node_modules\babel-loader\lib\index.js??ref--6-oneOf-2!C:\dev\Projects\learning-initiative\burger-builder\node_modules\axios\lib\defaults.js
When I use the imported object, it does not take the baseUrl from the instance I created.
MyAxios.post('/orders.json', order)
.then(response => console.log(response))
.catch(error => console.log(error));
Actually makes a request to http://localhost:3000/orders.json
. When I place a debugger and try to print the object to the console by typing MyAxios
it tells me Uncaught ReferenceError: MyAxios is not defined
.
Is this what the casing warning is referring to or am I missing something?
My package.json as requested:
{
"name": "burger-builder",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.19.2",
"prop-types": "^15.7.2",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-scripts": "3.4.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}