Questions tagged [fetch]

DO NOT USE. For questions about the JavaScript Fetch API, use the [fetch-api] tag instead. For the git subcommand, use [git-fetch]. This tag is ambiguous.

fetch is used in many contexts, include source control, database querying, and cache control.

References

11193 questions
27
votes
5 answers

Testing dispatched actions in Redux thunk with Jest

I'm quite new to Jest and admittedly am no expert at testing async code... I have a simple Fetch helper I use: export function fetchHelper(url, opts) { return fetch(url, options) .then((response) => { if (response.ok) { …
DanV
  • 3,193
  • 4
  • 29
  • 43
27
votes
2 answers

Can't send a post request when the 'Content-Type' is set to 'application/json'

I am working on a React application and I am using fetch to send a request. I have made a Sign Up form recently and now I am integrating it with it's API. Previously the API accepted url encoded data and it was all working fine. but now that the…
Arslan Tariq
  • 2,478
  • 2
  • 22
  • 45
26
votes
5 answers

Is there a performance difference between PDO fetch statements?

like in /* Exercise PDOStatement::fetch styles */ print("PDO::FETCH_ASSOC: "); print("Return next row as an array indexed by column name\n"); $result = $sth->fetch(PDO::FETCH_ASSOC); print_r($result); print("\n"); print("PDO::FETCH_BOTH:…
user397916
26
votes
4 answers

How to use OFFSET and Fetch without Order by in SQL Server

I want use OFFSET and Fetch in my SQL server 2012 query.But without any order by.I can not use order by.Because my sort order will be lost. How can I use OFFSET and Fetch without order by and row number and where in my query? My 2 select tables have…
25
votes
2 answers

Duplicates using left join fetch

I'm using a HQL query to obtain certain records. If I use LEFT JOIN FETCH a collection which is in my target entity will contain duplicate records. If I only use left join, it won't. I guess when Hibernate lazily loads the records, it avoids…
Daniel
  • 834
  • 1
  • 9
  • 25
25
votes
4 answers

fetch: Getting cookies from fetch response

I'm trying to implement client login using fetch on react. I'm using passport for authentication. The reason I'm using fetch and not regular form.submit(), is because I want to be able to recieve error messages from my express server, like:…
Gershon Papi
  • 5,008
  • 3
  • 24
  • 50
24
votes
4 answers

fetch API always returns {"_U": 0, "_V": 0, "_W": null, "_X": null}

The below code always return the below wired object {"_U": 0, "_V": 0, "_W": null, "_X": null} as response. Here is my code getData = () => { fetch('http://192.168.64.1:3000/getAll',{ method: 'GET', headers: { …
Kavinkumar . N
  • 311
  • 1
  • 2
  • 7
23
votes
5 answers

React Custom Hooks fetch data globally and share across components?

in this react example from https://reactjs.org/docs/hooks-custom.html, a custom hook is used in 2 different components to fetch online status of a user... function useFriendStatus(friendID) { const [isOnline, setIsOnline] = useState(null); …
MMMM
  • 3,320
  • 8
  • 43
  • 80
23
votes
1 answer

Disabling CORS using js fetch

I've looked into it and my syntax looks correct but I can't figure out what is going wrong. If I don't include the fetch options params, everything works fine except that CORS is on, which is what I do not want. After adding the options with mode:…
Anchalee
  • 636
  • 1
  • 5
  • 12
22
votes
4 answers

Safari: "Fetch API cannot load due to access control checks" after reload

I experience some odd behavior in the CORS system of Safari. I have a POST request which I send from the JS Fetch API like this: const res = await fetch('http://localhost:8888/myPath', { method: 'POST', mode: 'cors', headers: { …
h345k34cr
  • 3,310
  • 5
  • 21
  • 28
22
votes
1 answer

How can I resolve the error "URL scheme must be "http" or "https" for CORS request." for this code

It shows below message in the console. sandbox.js:1 Fetch API cannot load file:///C:/Users/Lizzi/Desktop/novice%20to%20ninja/todos/luigi.json. URL scheme must be "http" or "https" for CORS request I'm new to aynchronouse programming but I…
Elizabeth Essien
  • 233
  • 1
  • 2
  • 7
22
votes
1 answer

React Hooks and POST method

I need to understand how can I setup a custom hook in React, for a POST method. If I need to POST some data after a click, but I can't use the custom hook in an event handler, how can I do It? I made a custom Hook with all the fetch logic and the…
Fabio Russo
  • 271
  • 1
  • 3
  • 13
22
votes
11 answers

Git Giving "fetch first" error when trying to push

I am having my first introduction to git through a class I am taking. I have a number of files in a directory on my computer and am able to stage and commit them without a problem. However, when I try to push files to my github repository, I keep…
FizzikalGrafiti
  • 329
  • 1
  • 2
  • 7
22
votes
5 answers

Get total row count while paging

I have a search screen where the user has 5 filters to search on. I constructed a dynamic query, based on these filter values, and page 10 results at a time. This is working fine in SQL2012 using OFFSET and FETCH, but I'm using two queries to do…
user788312
  • 439
  • 2
  • 10
  • 22
22
votes
5 answers

PHP PDO with foreach and fetch

The following code: "; $sql = "SELECT * FROM users"; $users = $dbh->query($sql); foreach ($users as…
Eathen Nutt
  • 1,433
  • 5
  • 19
  • 27