weixin_33726313 2017-11-20 10:39 采纳率: 0%
浏览 198

Axios错误404错误

I'm having an issue where I think axios is querying the wrong URL just before query is sent.

getShows : function(){
  if( ! this.query ) return false;
  var getURL = this.makeUrlFromObject(this.query);
  console.log('getURL', getURL);
  var self = this;
  axios.get(getURL).then(function(response){
    console.log('response.data', response.data)
    self.shows = response.data;
  });
},
makeUrlFromObject : function(query){
  var queryArray = [];
  for (var prop in query) {
    if(!query.hasOwnProperty(prop)) continue;
    queryArray.push(prop + "=" + query[prop]);
  }
  var url = this.apiUrl + '?' + queryArray.join('&');
  return url;
},
...

Running the getShows returns the following in the console:

1. getURL /api/all?date=20180131

2. GET http://website.dev/shows/false 404 (Not Found)                     false:1

3. response.data (3) [{…}, {…}, {…}]

I can't seem to diagnose where this false:1 is coming from. The request and response are both working, just this extra request seems to crop up from nowhere.

  • 写回答

1条回答 默认 最新

  • weixin_33743703 2017-12-08 14:14
    关注

    I'm an idiot. Following the ajax request, an image element is created on the page.

    The response (not shown) happened to include an image file that was loaded into 2 of the 3 objects. The 3rd didn't have an image, so it came back as { image : false }.

    When this was then used to create an image template, it was coming back as:

    <div style="background-image:url(false)">
    

    So the console came back with a get request for 'false', which 404d.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题