isomorphic-fetch
isomorphic-fetch copied to clipboard
proxy for isomorphic-fetch
Prompt how to use isomorphic-fetch together with a proxy?
import fetch from 'isomorphic-fetch';
options = {
method,
timeout,
headers: {
'Cache-Control': 'no-cache',
'Content-Type': 'application/json; charset=utf-8',
'proxy': ?????
},
body: JSON.stringify(data)
};
return fetch(url, options)
I think you can't use proxy with client implementation. But for server version:
import fetch from 'isomorphic-fetch';
import proxyAgent from 'http-proxy-agent';
//import proxyAgent from 'https-proxy-agent'; // HTTPS
const options = {
method: 'GET',
agent: new proxyAgent('http://proxy:8080'),
body: JSON.stringify(data)
};
fetch(url, options)
did agent and http-proxy-agent solve it? can this be closed now?
It did solve for me.
import fetch from 'isomorphic-unfetch';
import HttpsProxyAgent from 'https-proxy-agent';
const res = await fetch('http://api.tvmaze.com/search/shows?q=batman', {agent: new HttpsProxyAgent('<myproxy>')});