小编Kin*_*ing的帖子

使用axios取消文件上传Post请求

我正在尝试实现取消功能,以在上传视频时取消视频的文件上传。这就是视频上传时我的前端的样子

在此输入图像描述

这是我使用 axios 发送请求的代码:

export function processPost (body, callback, errorUpdate) {
// config for post
var config = {
  timeout: 300000,
  headers: { 'content-type': 'multipart/form-data' }

}

// url for server endpoint
var url = 'http://localhost:5000/uploader'

// actual post
axios
  .post(url, body, config)
  .then(callback)
  .catch(function (error) {
    // Non 200 Response
    if (error.response) {
      errorUpdate('non 200 response from server')
      // Request made but no response received
    } else if (error.request) {
      errorUpdate('no response from server')
      // something else happened
    } …
Run Code Online (Sandbox Code Playgroud)

javascript cancel-button reactjs axios

1
推荐指数
1
解决办法
8696
查看次数

标签 统计

axios ×1

cancel-button ×1

javascript ×1

reactjs ×1