SuperAgent

Pipe superagent response to express response

余生长醉 提交于 2019-12-01 23:25:09
I'm trying to "proxy" some file with an express app. Why the code below doesn't work? var app = require('express')() var request = require('superagent') app.get('/image', function(req, res, next) { request('http://s3.amazonaws.com/thumbnails.illustrationsource.com/huge.104.520060.JPG') .then(function(_res) { _res.pipe(res) }) }) app.listen(3001, function() { console.log('listen') }) When I "wget" a file directly it works: $ wget http://s3.amazonaws.com/thumbnails.illustrationsource.com/huge.104.520060.JPG --2016-07-20 11:44:33-- http://s3.amazonaws.com/thumbnails.illustrationsource.com/huge

How to send files with superagent

你。 提交于 2019-11-30 18:11:00
问题 So about a month ago I asked a question regarding superagent and sending files, but got no response at all. I would still like to find out how to do this as I enjoy using superagent. I am able to send files using plain ajax: var fd = new FormData(); fd.append( 'file', this.refs.File.getDOMNode().files[0] ); $.ajax({ url: 'http://localhost:8080/files', data: fd, processData: false, contentType: false, type: 'POST', success: function(data){ console.log(data) } }); But when I try the same thing

webpack dev server CORS issue

寵の児 提交于 2019-11-30 04:35:13
I am using webpack-dev-server v1.10.1 to boost up my Redux project and I have the options below: contentBase: `http://${config.HOST}:${config.PORT}`, quiet: false, noInfo: true, hot: true, inline: true, lazy: false, publicPath: configWebpack.output.publicPath, headers: {"Access-Control-Allow-Origin": "*"}, stats: {colors: true} In the JS, I am using request from superagent to generate a HTTP GET call request .get(config.APIHost + apiUrl) .set('Accept', 'application/json') .withCredentials() .end(function (err, res) { if (!err && res.body) { disptach(() => { return { type: actionType || GET

webpack dev server CORS issue

泪湿孤枕 提交于 2019-11-29 01:43:54
问题 I am using webpack-dev-server v1.10.1 to boost up my Redux project and I have the options below: contentBase: `http://${config.HOST}:${config.PORT}`, quiet: false, noInfo: true, hot: true, inline: true, lazy: false, publicPath: configWebpack.output.publicPath, headers: {"Access-Control-Allow-Origin": "*"}, stats: {colors: true} In the JS, I am using request from superagent to generate a HTTP GET call request .get(config.APIHost + apiUrl) .set('Accept', 'application/json') .withCredentials()

Ensuring Express App is running before each Mocha Test

…衆ロ難τιáo~ 提交于 2019-11-28 18:22:09
I am working on developing a REST API using ExpressJS, NodeJS, Mongoose and Mocha. The thing is that I have an app.coffee file, thats responsible for setting up ExpressJS and connecting to Mongoose. The way I have set this up is that Mongoose is connected first and if that gets through, then, the ExpressJS App is started. The issue is that when setting up Mocha, I need to make sure that ExpressJS App existing in app.coffee is completely started successfully including all asynchronous code before any testcase is executed. For that, I have created a test_helper.coffee and placed the following

vue——cli 2.0 配置后台模拟

梦想的初衷 提交于 2019-11-28 10:51:04
在build文件夹中找到 webpack-dev-conf.js配置文件,在 const portfinder = require("portfinder"); 之后插入代码,导入express模块以及superagent(客户端请求代理)模块 const express = require("express"); const superagent = require("superagent"); // 客户端请求代理模块 导入模拟后台的数据以及设置路由变量 let appData = require("../mockdata.json"); // 加载本地数据 let self = appData.self; let friend = appData.friends; const app = express(); const apiRouter = express.Router(); app.use("/api", apiRouter); 在devServer属性中插入before属性 before(app) { app.get("/api/self", (req, res) => { res.json({ data: self }); }); app.get("/api/friends", (req, res) => { res.json({ data: friend });

Promise Error: Objects are not valid as a React child

柔情痞子 提交于 2019-11-28 09:39:59
I am trying to set the json to a state using user agent, I get the error: Uncaught Invariant Violation: Objects are not valid as a React child (found: object with keys {...}). If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons. method to set state: getInitialState: function(){ return { arrayFromJson: [] } }, loadAssessmentContacts: function() { var callback = function(data) { this.setState({arrayFromJson: data.schools}) }.bind(this); service.getSchools(callback); }, componentWillMount: function(){ this

Ensuring Express App is running before each Mocha Test

南笙酒味 提交于 2019-11-27 11:17:07
问题 I am working on developing a REST API using ExpressJS, NodeJS, Mongoose and Mocha. The thing is that I have an app.coffee file, thats responsible for setting up ExpressJS and connecting to Mongoose. The way I have set this up is that Mongoose is connected first and if that gets through, then, the ExpressJS App is started. The issue is that when setting up Mocha, I need to make sure that ExpressJS App existing in app.coffee is completely started successfully including all asynchronous code

Node.js爬虫实战 - 爬你喜欢的

不问归期 提交于 2019-11-27 10:21:38
前言 今天没有什么前言,就是想分享些关于** 爬虫 **的技术,任性。来吧,各位客官,里边请... 开篇第一问:** 爬虫 **是什么嘞? 首先咱们说哈,爬虫不是“虫子”,姑凉们不要害怕。 爬虫 - 一种通过一定方式按照一定规则抓取数据的操作或方法。 开篇第二问:** 爬虫 **能做什么嘞? 来来来,谈谈需求 产品MM: 爱豆的新电影上架了,整体电影评价如何呢? 暗恋的妹子最近又失恋了,如何在她发微博的时候第一时间知道发了什么,好去呵护呢? 总是在看小说的时候点到广告?总是在看那啥的时候点出来,澳xx场又上线啦? 做个新闻类网站没有数据源咋办? 研发GG: 爬虫 随时准备为您服务! 使用爬虫,拉取爱豆视频所有的评价,导入表格,进而分析评价 使用爬虫,加上定时任务,拉取妹子的微博,只要数据有变化,接入短信或邮件服务,第一时间通知 使用爬虫,拉取小说内容或xxx的视频,自己再设计个展示页,perfect! 使用爬虫,定时任务,拉取多个新闻源的新闻,存储到数据库 开篇第三问:** 爬虫 **如何实现嘞? 实现爬虫的技术有很多,如python、Node等,今天胡哥给大家分享使用Node做爬虫:爬取小说网站-首页推荐小说 爬取第一步-确定目标 目标网站: https://www.23us.so 我们要获取排行榜中六部小说的:书名、封面、以及小说书籍信息对应的地址(后续获取小说完整信息)