Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.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
Vue.js axios Vuejs未定义响应_Vue.js_Heroku_Axios - Fatal编程技术网

Vue.js axios Vuejs未定义响应

Vue.js axios Vuejs未定义响应,vue.js,heroku,axios,Vue.js,Heroku,Axios,我是使用axios的新手,我试图进行以下调用,但我收到一个未定义的响应错误 axios.get('https://galaxybank-atm.herokuapp.com/galaxybank/validateCard', { params: { card: 123456789, pin: 1234 }, responseType: 'json', timeout: 1

我是使用axios的新手,我试图进行以下调用,但我收到一个未定义的响应错误

axios.get('https://galaxybank-atm.herokuapp.com/galaxybank/validateCard', {
          params: {
            card: 123456789,
            pin: 1234
          },
          responseType: 'json',
          timeout: 10000
        })
        .then(function (response) {
          console.log(response);
        })
        .catch(function (error) {
          console.log(error);
        })
        .then(function () {
          // always executed
        });

         console.log(this.info)

       } catch (error) {
          console.log(error)
       }
网址:

可访问并作为响应提供json

我得到一个错误:

[object Error] {
  config: Object {
    adapter: function(e){return new Promise(function(t,f){var p=e.data,d=e.headers;r.isFormData(p)&&delete d["Content-Type"];var l=new XMLHttpRequest,h="onreadystatechange",m=!1;if("undefined"==typeof window||!window.XDomainRequest||"withCredentials"in l||a(e.url)||(l=new window.XDomainRequest,h="onload",m=!0,l.onprogress=function(){},l.ontimeout=function(){}),e.auth){var y=e.auth.username||"",w=e.auth.password||"";d.Authorization="Basic "+c(y+":"+w)}if(l.open(e.method.toUpperCase(),s(e.url,e.params,e.paramsSerializer),!0),l.timeout=e.timeout,l[h]=function(){if(l&&(4===l.readyState||m)&&(0!==l.status||l.responseURL&&0===l.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in l?i(l.getAllResponseHeaders()):null,r=e.responseType&&"text"!==e.responseType?l.response:l.responseText,s={data:r,status:1223===l.status?204:l.status,statusText:1223===l.status?"No Content":l.statusText,headers:n,config:e,request:l};o(t,f,s),l=null}},l.onerror=function(){f(u("Network Error",e)),l=null},l.ontimeout=function(){f(u("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED")),l=null},r.isStandardBrowserEnv()){var g=n(15),v=(e.withCredentials||a(e.url))&&e.xsrfCookieName?g.read(e.xsrfCookieName):void 0;v&&(d[e.xsrfHeaderName]=v)}if("setRequestHeader"in l&&r.forEach(d,function(e,t){"undefined"==typeof p&&"content-type"===t.toLowerCase()?delete d[t]:l.setRequestHeader(t,e)}),e.withCredentials&&(l.withCredentials=!0),e.responseType)try{l.responseType=e.responseType}catch(e){if("json"!==l.responseType)throw e}"function"==typeof e.onDownloadProgress&&l.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&l.upload&&l.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){l&&(l.abort(),f(e),l=null)}),void 0===p&&(p=null),l.send(p)})},
    data: undefined,
    headers: Object {},
    maxContentLength: -1,
    method: "get",
    params: Object {},
    responseType: "json",
    timeout: 10000,
    transformRequest: Object {},
    transformResponse: Object {},
    url: "https://galaxybank-atm.herokuapp.com/galaxybank/validateCard",
    validateStatus: function(e){return e>=200&&e<300},
    xsrfCookieName: "XSRF-TOKEN",
    xsrfHeaderName: "X-XSRF-TOKEN"
  },
  response: undefined
}
[对象错误]{
配置:对象{
适配器:函数(e){return new Promise(函数(t,f){var p=e.data,d=e.headers;r.isFormData(p)&&delete d[“Content Type”];var l=new-XMLHttpRequest,h=“onreadystatechange”,m=!1;if(“undefined”==typeof window | | |!window.XDomainRequest | | | |带凭证”在l | a(e.url)|(l=new window.xdinrequest,h=)中,h=,onload,h=,onprogress(),onm}{(一)政府当局当局当局当局当局当局当局当局当局当局当局当局当局当局当局当局当局当局当局当局当局当局(一)的{VAY=e.身份身份验证人士的密码124?"中,w=e.身份身份验证人士人士的身份身份验证人士的身份验证人士的身份验证人士的身份验证人士的身份验证人士的身份验证人士的身份验证人士的功能((一)函数(){{{}{}{}中,以及d.d.授权=“基本”c(c(y(c(y+,,,,,,,::::::::,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,“++++w)若)若)若)若)若)若若(若)若)若)若若若若(公公公公公公公文件:“){var n=l.i(l.getAllResponseHeaders())中的“getAllResponseHeaders”:null,r=e.responseType&“text”!==e.responseType?l.responseText,s={data:r,status:1223==l.status?204:l.status,statusText:1223==l.status?“无内容”:l.statusText,头:n,配置:e,请求:l};o(t,f,s),l=null},l=onerror=function(){f(u(“网络错误”),e},l.ontimeout=function(){f(u(“超时”+e.timeout+“毫秒超过”,e,“econnoborted”)),l=null},r.isStandardBrowserEnv(){var g=n(15),v=(e.withCredentials | a(e.url))&&e.xsrfCookieName?g.read(e.xsrfCookieName):void 0;v&&d[e.xsrfHeaderName]=v}如果l&&r.forEach(d,function(e,t)中的“setRequestHeader”为未定义的内容类型“&=”为删除d[t]:l.setRequestHeader(t,e}),e.withCredentials&(l.withCredentials=!0),e.responseType)尝试{l.responseType=e.responseType}捕捉(e){if(“json”!==l.responseType)抛出e}“函数”==e.onDownloadProgress和l.addEventListener的类型(“progress”,e.onDownloadProgress),“函数”==e.OnUpload和l.upload.addEventListener的类型(”progress“,e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(函数(e){l&&l.abort(),f(e),l=null)}),void 0==p&&p(p=null),l.send(p)},
数据:未定义,
标题:对象{},
maxContentLength:-1,
方法:“获取”,
参数:对象{},
响应类型:“json”,
超时:10000,
transformRequest:对象{},
transformResponse:对象{},
url:“https://galaxybank-atm.herokuapp.com/galaxybank/validateCard",

validateStatus:function(e){returne e>=200&&e我通过在spring服务中更改Cors配置来解决它

@Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurerAdapter() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/**")
                        .allowedMethods("HEAD", "GET", "PUT", "POST", "DELETE", "PATCH");
            }
        };
    }

请把准确的地址寄出去error@ShivamSingh我只是添加了一个错误您的浏览器控制台中应该有一个CORS错误。CORS阻止跨源请求,除非服务器已启用它们。如果您对服务器有控制权,您可以启用CORS。如果使用其他源向未启用CORS的服务器发出请求,则必须从b类似于ackend的节点,而不是浏览器。这是一种浏览器安全功能。您应该能够找到大量有关CORS的信息/问题,以进一步帮助您。嗨,Dan,非常感谢您的回答。我真的帮了我大忙!我在heroku的Spring boot服务中设置了CORS,现在可以拨打axios电话:-)