Questions tagged [isomorphic-fetch-api]

Fetch for node and Browserify. Built on top of GitHub's WHATWG Fetch polyfill. Questions relating directly to isomorphic-fetch should use this tag. Questions relating to window.fetch polyfil should use the fetch-api tag.

isomorphic-fetch adds fetch to and built ontop of the fetch polyfil.

The fetch() function is a Promise-based mechanism for programmatically making web requests in the browser. This project is a polyfill that implements a subset of the standard Fetch specification, enough to make fetch a viable replacement for most uses of XMLHttpRequest in traditional web applications.

65 questions
93
votes
3 answers

How to set the content-type of request header when using Fetch APi

I am using npm 'isomorphic-fetch' to send requests. The problem I am experiencing is I am unable to set the content-type of the request header. I set a content type of application/json , however the request header are being set to text/plain. import…
71
votes
2 answers

What is the difference between isomorphic-fetch and fetch?

I've seen two different fetch here: https://github.com/github/fetch https://github.com/matthew-andrews/isomorphic-fetch Can someone tell me the difference between the two? PS: I've read the README.md but I still didn't get the difference. Last…
Joshua Rajandiran
  • 2,788
  • 7
  • 26
  • 53
22
votes
2 answers

How to properly polyfill URLSearchParams in webpack?

I have a project that uses fetch polyfill from isomorphic-fetch. I would like to use URLSearchParams with it to submit POST data. For fetch to support URLSearchParams it first checks if it is available in global object. I though to use this polyfill…
Max Semikin
  • 974
  • 1
  • 11
  • 19
19
votes
5 answers

Relative URL as hostname in Nock

I need to mock client side HTTP requests. I'm using isomorphic-fetch in the client side and I'm using mocha and nock for testing and mocking. All my client requests are based on relative path. Due to this I'm unable to provide host name for the…
Pranesh Ravi
  • 18,642
  • 9
  • 46
  • 70
15
votes
3 answers

Typescript - Cannot find name 'fetch' (universal library)

I'm aiming to build a Typescript library with AJAX calls (by using the fetch API), that can be used by both client-side (Webpack/Browserify) and back-end developers (Node). However, I can't seem to get the fetch to compile without errors. My first…
zurfyx
  • 31,043
  • 20
  • 111
  • 145
15
votes
3 answers

How to dispatch an action on page load in react-redux?

I have to display a table with lot of data. There is a pagination button which display 10 record per page. I have one button called "FETCH" on-click of it table is populating. How do load my table on load of the page. action.js import fetch from…
Raj Rj
  • 3,497
  • 4
  • 24
  • 34
15
votes
2 answers

Use fetch instead of ajax with redux-observable

In redux-observable is it possible to use isomporphic-fetch instead of Rx.DOM.ajax?
Amio.io
  • 20,677
  • 15
  • 82
  • 117
14
votes
2 answers

How to POST with multipart/form-data header and FormData using fetch

This is a CURL example which works fine: curl -X POST \ \ -H 'authorization: Bearer ' \ -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \ -F file=@algorithm.jpg \ -F userId= I'm…
rfc1484
  • 9,441
  • 16
  • 72
  • 123
7
votes
3 answers

Sending a details request to Google Places API - (CORS error)

I'm trying to augment the collection of photos I have for public artworks in this project I'm working on with photos from the Google Places API. It says here that you can send a details request to get an array of ten photos. Eventually I will unpack…
6
votes
1 answer

Googlebot and empty CORS responses

We have a React app that loads some data asynchronously from another domain. The requests are made using isomorphic-fetch in cors mode and the requests and responses all look fine and work correctly when testing using my own browser. We have…
El Yobo
  • 14,823
  • 5
  • 60
  • 78
5
votes
1 answer

ReactJS Cannot read property setState of undefined

I am new to ReactJS, and somewhat understand that this question is duplicated to numeral questions in SOF. But I hope someone can give me some directions and clarifications on some concepts of React. What I want to do is simply get data from remote…
Ellery Leung
  • 617
  • 3
  • 10
  • 23
5
votes
3 answers

React Native Error - Can't find variable: self

After adding a node module,isomorphic-fetch(version : ^2.2.1) in React Native app, I am getting an error of Can't find variable: self. Here I have attached a screenshot. The error is thrown from the file, located at node_modules > isomorphic-fetch…
Nirav Dangi
  • 3,607
  • 4
  • 49
  • 60
3
votes
3 answers

How to make fetch promise resolve without using .then syntax?

First things first, I made sure to write a quick demo of the issue I'm talking about here https://codesandbox.io/s/exciting-swirles-7cs3s But essentially, using the isomorphic-fetch library, I'm running into an issue where I can't really get the…
notacorn
  • 3,526
  • 4
  • 30
  • 60
3
votes
3 answers

Why is "Promise { }" not resolving?

I am trying to fetch data from the Storm Glass API. I am using their template Fetch request (https://docs.stormglass.io/?javascript#point-request). When I run the script the console reads out "Promise { }" indefinitely. So, the request…
Booncat
  • 33
  • 4
3
votes
0 answers

Basic auth is not working properly using isomorphic-fetch in GET call

Passing Authentication param properly in headers but it is get converted into WWW-Authenticate:Basic realm="Realm" in the response headers. Below is my code snippet of get api call. doGetAuthRaceReplay (url) { var param = this._doGetParam({ …
Kalashir
  • 1,099
  • 4
  • 15
  • 38
1
2 3 4 5