使用来自客户端javascript的superagent发布多部分表单数据

时间:2015-05-27 07:26:46

标签: javascript node.js superagent

我试图在客户端javascript上使用superagent来向我的nodejs后端发出一个多部分表单发布请求。

只有attach()和part()方法才能解决错误

我的代码如下:

superagent
  .post('/api/audio')
  .attach('file', '/music/music.mp3' )
  .end(function(err, res){
    console.log(res.text);
  });

我是根据他们的文档http://visionmedia.github.io/superagent/#multipart-requests写的,但它给我一个错误:

Uncaught TypeError: superagent.post(...).attach is not a function

我哪里错了?

0 个答案:

没有答案