axios请求接口

1.非json格式
var me=this;
let fd = new FormData()
fd.append(‘file’, f.file)
fd.append(‘fid’,this. r o u t e . p a r a m s . i d ) ; / / f d . a p p e n d ( s c o r e , t h i s . f j s c o r e ) ; c o n s o l e . l o g ( f d ) m e . route.params.id);//传其他参数 fd.append('score',this.fjscore); console.log(fd) me. axios.post(me.url+"/file/uploadfile", fd)
.then(function (result) {
if(result.data.resulttrue){
me.KaTeX parse error: Expected 'EOF', got '}' at position 167: … }̲ …message({
message: result.data.msg,
type: ‘error’
})
}
})
在这里插入图片描述
2**.json格式的**
var para = {
tid:this.tid,
title: this.title,
content: this.content,
page:this.radio,
score:this.score
};
var me=this;
me.KaTeX parse error: Expected '}', got 'EOF' at end of input: … me.message({
message: ‘发帖成功’,
type: ‘success’
})
me.KaTeX parse error: Expected '}', got 'EOF' at end of input: …th: `/noteList/{me.tid}`
})
}
if(result.data.result
false){
me. m e s s a g e ( m e s s a g e : r e s u l t . d a t a . m s g , t y p e : e r r o r ) m e . message({ message: result.data.msg, type: 'error' }) me. router.push({path: ‘/login’});
}
})
在这里插入图片描述