fetch-api Questions

5

Solved

I'm doing a POST request from my frontend using fetch API. But when I tried in Firefox, it doesn't work. In Chrome works fine. Here's what I'm trying to do. const handleSubmit = async event =&gt...
Pergrim asked 4/12, 2019 at 12:51

2

I'm trying to work with the eBay APIs. It's a small personal project that just needs to run locally, and although I know C#, I'm much more comfortable with Javascript so I'm looking for ways to get...
Halette asked 11/4, 2021 at 20:27

4

I was trying the Next 13 beta version, and I faced a strange problem. What I am trying to do is, fetch data on the server side and display them on the page. However, the "fetch" operation...
Nierman asked 13/12, 2022 at 3:31

5

Solved

I was getting an error when returning response.json() when I would do a request with an empty response body, so I'm trying to just return an empty object when there is an empty body. The approach I...
Taxidermy asked 15/1, 2018 at 16:7

3

Solved

I am working on a React frontend to chart some data from a fastapi backend. I am using a couple of dropdown components to change the month and year for the requested data. With the initial render t...
Bondmaid asked 1/11, 2023 at 18:12

2

Solved

I am doing console.log("navigating"); var rsp = await fetch(params.url, { credentials: "include", redirect: "manual", mode: "cors" }); console.log(rsp); rsp.headers.forEach(console.log); c...
Librate asked 5/10, 2018 at 12:59

5

Solved

So I have some code like this: async function getData() { const response = await fetch(/* ... */); const json = await response.json(); return transform(json); } Where transform can throw some...
Eligibility asked 9/4, 2020 at 3:10

4

I'm getting a TypeError: Failed to fetch error when I attempt to send a post request using fetch on the front-end and an express route on the back-end. I'm able to successfully create the new user...
Downs asked 4/7, 2019 at 17:7

1

I have written logic based on test cases already defined.Basically the tc checks for one server call below is the code.How do I modify my logic to make the tc pass? this is test case: it('there s...
Malpighiaceous asked 4/6, 2019 at 1:16

6

I thought useEffect is called once only after render, but it's being executed multiple times and not in the order I expected. I expected it to msg 'data loading' while the fetch is in progress and ...
Bacteria asked 29/6, 2020 at 4:6

6

Solved

I have a Node/Express backend and I'm consuming the API with a React Client. I want to be able to set the authorization header after a user is signed up. This ensures that subsequent requests are s...
Intine asked 6/8, 2017 at 19:40

6

Is it possible, using the fetch API, to set default headers for every single request? What I want to do is set an Authorization header whenever there is a json web token in the localStorage. My cur...
Baste asked 29/6, 2017 at 8:57

13

I saw several posts on the subject but without result. I have on the one hand a form which collects information (name, first name etc) then saves it in database (mongodb). Everything works when I u...
Stroy asked 11/3, 2020 at 15:56

7

Solved

I'm trying to get JSON saved into a variable, but it seems I don't understand everything here. I get JSON show up in console a once the way I like, but after I try to call it again later it only re...
Godroon asked 27/1, 2018 at 10:46

17

Solved

I'm using fetch API within my React app. The application was deployed on a server and was working perfectly. I tested it multiple times. But, suddenly the application stopped working and I've no cl...
Pneumococcus asked 17/3, 2018 at 23:38

3

Solved

I got this error after updating to angular 17: NG02801: Angular detected that `HttpClient` is not configured to use `fetch` APIs. It's strongly recommended to enable `fetch` for applications that ...
Ellsworthellwood asked 19/11, 2023 at 21:53

6

Solved

I've been messing around with the fetch() api recently, and noticed something which was a bit quirky. let url = "http://jsonplaceholder.typicode.com/posts/6"; let iterator = fetch(url); iterato...
Burin asked 31/5, 2016 at 20:26

11

Solved

I am trying out the new Fetch API but is having trouble with Cookies. Specifically, after a successful login, there is a Cookie header in future requests, but Fetch seems to ignore that headers, an...
Fancher asked 1/1, 2016 at 17:21

19

Solved

I'm trying to POST a JSON object using fetch. From what I can understand, I need to attach a stringified object to the body of the request, e.g.: fetch("/echo/json/", { headers: { 'Acce...
Loraineloralee asked 21/4, 2015 at 14:54

4

Solved

I have this code in my app/page (Server Component): const getUsers = async () => { const result = await fetch('/api/users', {method: 'GET'}); if (result.ok) { return result.json(); } return...
Rescue asked 22/5, 2023 at 18:55

9

I'm using fetch to get data json from an api. Works fine but I have to use it repeatedly for various calls, thus it needs to be synchronous or else I need some way to update the interface when the ...
Sop asked 24/6, 2017 at 10:59

4

I'm working with an odata api, and when I'm using postman to do a GET request, works perfect and I get the response as I was expecting. But when I use a fetch request from my React app, the reque...
Lobule asked 1/3, 2018 at 14:3

2

Solved

In chrome developer tools is very useful to "replay xhr" for a xhr request (network tab). I have started using fetch in my code, and chrome developer tools do not allow to "replay" a fetch request,...
Imprimis asked 20/3, 2017 at 16:28

5

Solved

I'm trying to making a weather app that displays the weather and the temperature of many days of the week. I'm currently using openweathermap api for such task, the thing is that the information th...
Cabbage asked 8/6, 2016 at 5:34

8

Solved

I want to send a new FormData() as the body of a POST request using the fetch api The operation looks something like this: var formData = new FormData() formData.append('myfile', file, 'someFileNam...
Granitite asked 1/9, 2016 at 20:33

© 2022 - 2025 — McMap. All rights reserved.