我正在遵循Brad Traversy在Axios上的课程,而我刚接触拦截器。我遵循了他写的内容,但出现一个错误:
ReferenceError: Data is not defined
<anonymous> http://localhost:63342/Asynchronous JS/axios-notes/main.js:87
promise callback*r.prototype.request https://unpkg.com/axios/dist/axios.min.js:2
e https://unpkg.com/axios/dist/axios.min.js:2
exports https://unpkg.com/axios/dist/axios.min.js:2
getTodos http://localhost:63342/Asynchronous JS/axios-notes/main.js:14
EventListener.handleEvent* http://localhost:63342/Asynchronous JS/axios-notes/main.js:134
这是我的拦截器代码:
axios.interceptors.request.use(
config => {
console.log(`${config.method.toUpperCase()} request sent to ${config.url} at ${new Data().getTime()}`);
return config;
},
error => {
return Promise.reject(error);
}
);
一旦我删除了这段代码并执行了get / post请求,一切都会再次正常工作,这意味着这段代码有问题。