Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/434.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我的Vuejs应用程序无法使用axios发送http post_Javascript_Vue.js_Post_Axios - Fatal编程技术网

Javascript 我的Vuejs应用程序无法使用axios发送http post

Javascript 我的Vuejs应用程序无法使用axios发送http post,javascript,vue.js,post,axios,Javascript,Vue.js,Post,Axios,在我的Vuejs应用程序中,我试图向我的服务器发送HTTP post,我在控制台中不断收到此错误 TypeError: _api__WEBPACK_IMPORTED_MODULE_0__.default.post is not a function at Object.coursePix (services.js?87e7:5) at VueComponent._callee$ (testCourse.vue?8c89:98) at tryCatch (runtime.j

在我的Vuejs应用程序中,我试图向我的服务器发送HTTP post,我在控制台中不断收到此错误

TypeError: _api__WEBPACK_IMPORTED_MODULE_0__.default.post is not a function
    at Object.coursePix (services.js?87e7:5)
    at VueComponent._callee$ (testCourse.vue?8c89:98)
    at tryCatch (runtime.js?96cf:45)
    at Generator.invoke [as _invoke] (runtime.js?96cf:271)
    at Generator.prototype.(anonymous function) [as next] (webpack-internal:///./node_modules/regenerator-runtime/runtime.js:97:21)
    at asyncGeneratorStep (asyncToGenerator.js?3b8d:5)
    at _next (asyncToGenerator.js?3b8d:27)
    at eval (asyncToGenerator.js?3b8d:34)
    at new Promise (<anonymous>)
    at new F (_export.js?63b6:36)
这是services.js

import api from '@/api'

export default {
    coursePix (credentials) {
        return api.post('coursePix', credentials)
    }
}
和upload.vue

async AddCourse(){
    const formData = new FormData()
    formData.append('file', formData)
    var obj = {
        send: 'send'
    }
    try{                
        await services.coursePix(obj)
    }
    catch(err){
       console.log(err)
   }
}

我尽我所能尝试了一切,但都不起作用,我如何解决这个问题,或者我做错了什么

似乎您没有检索ajax实例:

return api.post('coursePix', credentials)
return api().post('coursePix', credentials)
而不是:

return api().post('coursePix', credentials)