javascript - React axios - TypeError:无法读取未定义的属性'post'
问题描述
我正在尝试使用在我的反应应用程序中发出发布请求Axios
,但我TypeError
每次都得到。这是我的代码:
submitHandler = (e) => {
e.preventDefault();
axios.post('https://jsonplaceholder.typicode.com/posts', this.state)
.then(response => {
console.log(response);
})
.catch(error =>{
console.log('error');
})
}
这是我每次提交表单时得到的
这是我的进口:
import './Form.css';
import React, { Component } from 'react'
import axios from 'axios'
TypeError: Cannot read property 'post' of undefined
好像是axios的错误,我检查了很多次安装都没有发现问题出在哪里。有人能帮我吗? 这是我的问题的代码沙箱 提前谢谢。
解决方案
推荐阅读
- python - 使用布尔系列将 Pandas 数据帧转换为结构化数组
- java - 使用 Java 驱动程序 3.8 从 MongoDb 中提取 ISODate 作为日期字符串
- python-3.x - 与 python3.6 相比,使用 python3.7 的 pytest 运行时间几乎长 10 倍
- vba - 如果单元格有背景颜色,则删除整行
- javascript - 当渲染方法中没有使用 observable 时,如何让 MobX 更新组件?
- javascript - JavaScript Array.concat 和推送解决方法
- ios - UIActivityViewController excludeActivityTypes 不适用于自定义 UIActivityTypes
- php - 检查进程正在使用哪些文件?
- unix - 从每列中删除第一个和最后一个连字符
- php - mPDF-如何在表格的行上应用自动换行符