javascript - Angular HttpClient POST 请求在 upLoadByFile 方法 EditorJs 中不起作用
问题描述
我正在尝试将 EditorJs 集成到我的 Angular v10.1.7 应用程序中。但是在图像配置中,我不能使用来自 Angular HttpClient 的 POST 请求将请求发送到我的服务器。
这是代码:
image: {
class: ImageTool,
config: {
uploader: {
uploadByFile(file) {
let formData = new FormData();
formData.append('image', file, this.title);
this.httpClient.post(this.NEWS_URL + 'image', formData)
.subscribe((res) => {
return {
success: res.success,
url: res.url,
};
});
},
},
},
},
和错误:
Image Tool: uploading failed because of TypeError: Cannot read property 'post' of undefined
我该如何处理这个问题?是否有任何替代解决方案可以在不使用 Angular HttpClient 的情况下将文件发送到服务器?
解决方案
推荐阅读
- javascript - for..in 循环和 Object.keys 不同的行为
- javascript - WebGL2 texImage2D 16-bit then readPixels 16-bit问题
- flutter - 如何控制 FLutter 的 audio_service 包中通知栏中显示的内容
- mysql - 根据顺序行模式的匹配将 SQL 行折叠成一行
- java - 通过 Apache Flink 将 SQL Query 的结果写入文件
- c# - 如何在C#中将类对象序列化为JSON字符串时动态设置键名
- plot - 如何在热图中添加等高线
- excel - Excel IE 自动化识别并作用于 Tab Strip 'css' 元素 (encore)
- javascript - 来自 CreateEntityAdapter 的 SetAll 不使用 react redux 工具包设置状态
- vba - 使用字符串中的子字符串更新 MS Access 数据库的 VBA