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 关于#python#的问题:求帮写python代码
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?