我在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请求,一切又都正常了,这意味着这段代码有问题。
1条答案
按热度按时间jyztefdp1#
请检查此行的日期对象是否正确,是
new Date()
,而不是new Data()
字符串
将其校正成
型