Fuse Community

Fetch API New Features.

Hi Fuse Team.

 

These 2 features which I believe should be added to the FuseJS Fetch API. It will provide some good control over network requests to users. If you are developing a mobile app you should feel like it :slight_smile:

 

My main feature request for Fetch API is::

  • Prevent the request from being redirected.

    For example :

fetch(new Request('https://goo.gl/ksHc8v', {
	options: {
		redirect: 'prevent',
	},
})).then((resp) => {
	// THE resp Object SHOULD BE AS FOLLOWS
	// resp.status [= 301, 302]
	// resp.headers.get('location') [= 'https://slack.com/api/api.test']
	// OR Even better if you can add resp.redirectURI = [= 'https://slack.com/api/api.test']
}).catch((fail) => {
	console.log(fail);
});
  • Preserve the request cookies upon redirection.
let headers = new Headers();

headers.set('Cookie', 'A=B');

fetch(new Request('https://goo.gl/ksHc8v', {
	headers: headers,
	options: {
		cookies: 'preserve',
	},
})).then((resp) => {
	// 'Cookie' HEADER SHOULD BE PASSED AS IT IS TO WHATEVER NUMBER OF REDIRECTED REQUESTS IT TAKE
	console.log(resp);
}).catch((fail) => {
	console.log(fail);
});

Thank you for your suggestions. We already have this in the backlog, I’ve attached this thread to the internal issue, so you can get notified when something happens.