【发布时间】:2018-08-26 18:15:48
【问题描述】:
我已经在我的项目中设置了 axios,
在我的 src/ 文件夹中创建了一个如下所示的 axios.js 文件:
import axios from 'axios';
const instance = axios.create({
baseURL : 'https://myprojectname-11651.firebaseio.com/'
});
export default instance;
然后在我使用 axios 的主要组件中,我像这样使用它:
import axios from '../axios.js';
// removing code thats not necessary for this example
componentDidMount() {
// alert();
axios.get('/habits/badHabits.json')
.then( (resp) => {
console.log(resp);
})
}
我的控制台出现 401 错误,firebase 的仪表板似乎从一年前发生了变化,我无法像一年多前那样将 axios 与 firebase 一起使用。
我的数据库是这样的:
我究竟如何将 axios 与 firebase 一起使用?我必须从 npm 安装 firebase 吗?
【问题讨论】: