6,221 questions
1
vote
2
answers
68
views
Why is my fetch POST request returning 415 Unsupported Media Type?
I’m trying to send a JSON payload to my backend API using fetch in React, but the server keeps returning:
415 Unsupported Media Type
Here is the code I'm using:
const sendData = async () => {
...
0
votes
1
answer
110
views
Why does CORS apply to local files? And is there a way to just disable it? [duplicate]
I have been working on a personal project for a while now and during a testing phase for a database, it began reporting that CORS was preventing the file from being fetched, and stopped my testing in ...
0
votes
1
answer
91
views
javascript fetch and redirect through flask view not working as expected
In the html intro to a web app for a scientific study, data is collected through forms.
I added a javascript function that submits the data via the fetch API:
fetch('/prepare/', {
"method":...
0
votes
0
answers
86
views
What’s the correct way to fetch this API from the client side without hitting CORS errors? [duplicate]
I’m trying to call an external API from my JavaScript code using the fetch() method. It works perfectly on my local environment, but when I upload the same code to my website, I get a CORS error like ...
1
vote
1
answer
55
views
Save button in Laravel Blade + JavaScript fetch not triggering (no console log, no network request)
I’m working on a Laravel Blade view (monitoring.blade.php) where I have an edit and save button for each row. The edit button works, but when I click the save button, nothing happens — no console logs,...
-5
votes
0
answers
218
views
Thunderbird equivalent of browser.runtime.getURL()?
I want to use the JS Fetch API from within a Thunderbird extension. However, I need a URL to get me started. In a browser extension, I would write:
let url = browser.runtime.getURL("beasts/frog....
4
votes
1
answer
125
views
Why I cannot send body with a fetch request when mode is no-cors?
Trying to make a cross-origing fetch request with the no-cors mode I found out it is not possible in this case to send any data to the server as a body:
const url = 'http://cross-origin-example.com/...
0
votes
1
answer
58
views
TMDb API Error: signal timed out when fetching popular movies
Problem:
I’m trying to fetch popular movies from the TMDb API in my Next.js project, but I keep getting a signal timed out error.
Here’s the error log:
TMDb API Error: signal timed out
at ...
1
vote
0
answers
117
views
Why does my API call in Next.js return undefined even though the Express backend works fine?
I’m building a small full-stack project using Next.js (frontend) and Express.js (backend) with a MySQL database.
The Express backend has this route:
// server.js
import express from "express&...
0
votes
1
answer
68
views
Why doesn't useState update correctly in my custom useFetch hook?
I'm trying to write a custom React hook that fetches data. It seems to work partially — but loading goes false before data is set, and error is never set even when a request fails.
import { useState, ...
0
votes
0
answers
88
views
How does a .NET Controller know to apply the CancellationToken = default [duplicate]
EDIT 2 (please reinstate this question)
As (see below) the CancellationToken is NOT sent from caller to callee of an API, how does .NET C# know to apply the default= option of a Controller methods' ...
0
votes
0
answers
29
views
Importing @babel/traverse breaks files
As the title says.
This code reproduces the issue.
My environment: Windows 11, ArchWSL, Volta, [email protected], [email protected]
import fs from "node:fs";
import { Buffer } from "node:buffer&...
2
votes
1
answer
148
views
Why does setTimeout execute before fetch .then despite microtask priority? [duplicate]
I'm running the code below. The output I was expecting was:
Start -> End -> While expires -> joke -> setTimeout
However, the output I’m actually getting is:
Start -> End -> While ...
-1
votes
1
answer
66
views
Updating the cart by fetch request
I have a code for updating the quantity in the cart by a fetch() request, and I modified it a little:
updateMainItem(line, quantity, name, variantId) {
const body = JSON.stringify({
line,
...
1
vote
1
answer
63
views
Why does my async function return a pending Promise instead of the expected value in JavaScript? [duplicate]
I’m trying to call an async function and get the result, but instead of the actual data, I get a pending Promise. Here’s a simplified version of my code:
async function getData() {
const response = ...
-4
votes
1
answer
124
views
Asynchronously and quickly make many API requests in JavaScript while handling or preventing 429 CORS error messages [closed]
How can I asynchronously create two hundred API requests in a quick manner to an API, that is https://api.dictionaryapi.dev, in JavaScript? I want to catch CORS errors with an error status of 429 ...
0
votes
2
answers
295
views
How can I automatically refresh the token and retry the fetch request after receiving a 401 response?
const acceptRequest = async () => {
try {
const res = await fetch(`${process.env.NEXT_PUBLIC_SOCKET_SERVER_URL}/acceptRequest`, {
method: "POST",
body: JSON....
0
votes
0
answers
52
views
CloudFront serving different file version based on request type
I have updated a PDF file in my Amazon S3 bucket. The bucket in question is being served by a CloudFront distribution.
I have successfully executed an invalidation and when I access the PDF file by ...
0
votes
1
answer
109
views
How to create a common class in Flutter for managing GET and POST requests using the http package?
I'm working on a Flutter project where I make multiple API calls using the http package. Right now, I'm writing separate get and post methods in different files, which is causing code duplication and ...
0
votes
1
answer
77
views
TLS Error with Octokit but not Native Fetch
I am in the process of upgrading a job script that previously ran using NodeJS 16.x, upgrading to NodeJS 22.x.
This is a pretty simple script that contains some API calls to GitHub using Octokit.
The ...
0
votes
0
answers
22
views
Clarifying Service Worker Fetch Event Limitations: Like scope
I have been experimenting with proxying requests using a service worker (SW) fetch event listener and have been seeing behaviour I thought wasn't possible, at least according to AI, and reading ...
-2
votes
1
answer
102
views
doPost(e): e.postData is Undefined for POST Request from Netlify with application/json [closed]
I'm building a website hosted on Netlify that submits a form to a Google Apps Script web app. The form data is sent as JSON with the Content-Type: application/json header using the fetch API.
The ...
-5
votes
2
answers
125
views
When using window.fetch is there a way to actually "submit()" the form?
Say I have a web page and I want it to automatically "go to" some form. This sort of thing works fine:
script(type = 'text/javascript').
var ff = document.createElement("form")
...
1
vote
1
answer
137
views
Why is my patch request being blocked despite PATCH being allowed by the server's CORS policy?
The Gist API explicitly allows any * host and the PATCH method:
access-control-allow-origin: *
access-control-allow-methods: GET,PUT,PATCH,OPTIONS,POST
However, when a PATCH request is issued from a ...
3
votes
1
answer
297
views
How to pass a List of strings as FormData to FastAPI using JavaScript Fetch API?
This is the Next.js frontend:
// Create FormData to send files, URLs and username to the API
const formData = new FormData();
if (files && files.length > 0) {
files.forEach((file) =>...
1
vote
1
answer
44
views
How can I instantiate a FetchEvent in my deno test?
I'm testing my Service Worker library that accepts a FetchEvent as an input. In my tests, I want to instantiate a FetchEvent to test my library but instead I get:
error: ReferenceError: FetchEvent is ...
1
vote
1
answer
102
views
.querySelector method returning "is not a function" error
Been getting back into programming after a pretty long while, I decided I would play around with http requests in javascript to build a web scraper later, I wrote this little guy to practice a bit:
...
1
vote
1
answer
92
views
When I make a fetch request then take out the JSON, instead a promise is saved as a variable with the correct JSON in it
When I make a fetch request then take out the JSON, instead a promise is saved as a variable with the correct JSON in it. I can not figure out how to pull the data from the promise in the variable in ...
0
votes
0
answers
30
views
How to fetch automatic refreshed token from XHR?
Some websites update JWT regulary to prevent scraping: in browser JS sends XHR to server to get fresh token- see the Token XHR on the picture below. Eg.
curl "https://www.nemlig.com/webapi/Token&...
1
vote
1
answer
77
views
ajax/fetch promise not resolving in Chrome iOS mobile [root cause unrelated]
Similar questions
chrome mobile jquery ajax POST not working = Seems like it should be the same problem, but asker apparently was unable to reproduce after publishing to remote server.
Context
...
0
votes
0
answers
52
views
Relative paths for Javascript fetch inside a Thunderbird extension
I'm trying to use window.fetch() in a Thunderbird extension I'm working on. Specifically, I want to try fetching the contents of files using relative paths - but am failing, possibly because I'm not ...
1
vote
0
answers
74
views
Why is a fetch of missing resource's URI take me straight to the catch block?
I'm using the Fetch API for the first time, running some code within a (recent version of) Thunderbird:
let uri = whatever();
window.fetch(uri)
.then((response) => {
console.log(`got response ...
0
votes
1
answer
50
views
can not make a multi form post request via JS run without error
First Question
I have a route tested in insomnia which is working
The route is sent as\with multiform option
also, I have to set\change the preferences in insomnia not to validate SSL
However, I can ...
0
votes
0
answers
59
views
Why does javascript fetch call not enable me to read contents of the file? [duplicate]
I am trying to get a web page to read text from files held on the same webserver. The following is the code I am using; it is cobbled together from several much-praised answers to similar questions ...
0
votes
2
answers
69
views
Non Expected Format of JSON Received By Express App (Sent By Fetch API)
I am new to nodejs/express and I have stumbled across a seemingly simple, yet annoying, problem in a web app I am developing. Essentially, I am trying to send a post request to an Express App that ...
0
votes
0
answers
129
views
How to close stream with server-side event using fetch?
so I'm using server-side events to push messages from the server to the frontend. For front end. I'm using fetch to start the stream, like this
const response = await fetch(`${API_URL}/hello`, {
...
0
votes
0
answers
40
views
How to keep fetch working when iOS minimizes the browser?
I'm working on a web application using Laravel, Nginx on the server, Express for the "API" and I'm facing an issue with session management when users switch tabs or minimize the browser. (At ...
0
votes
1
answer
90
views
Suspense does not work on nextjs, waiting promise but not displaying loading dialog
"use client";
import React, { Suspense, useEffect, useState } from "react";
import TopBar from "../components/topBar";
import DataPost from "../components/data"...
1
vote
1
answer
223
views
NextJs does not log the fetch on the DevTool but it does on the terminal - Why?
Why can't I see the fetch log information in the Chrome DevTool, but I can see it from the terminal?
Context
I'm used to debug my NextJs app using the DevTool, also for the Server-side code.
So I run ...
1
vote
0
answers
80
views
FastAPI response does not come through to Angular frontend
I am pretty new to fast API and angular. I am getting an issue where in angular the response never fully gets sent. When I use postman or curl the response is fully there but for some reason it always ...
0
votes
1
answer
41
views
Having trouble using fetch API to load ASP.NET MVC partial view which includes Quill rich-text editors
I am trying to use fetch to load a partial view which includes several Quill containers. Using Fetch, the Quill editors are not rendered. There is no comparable problem using jQuery's load method.
...
0
votes
1
answer
66
views
I'm struggling to adapt FullCalendar to push a selection event to my api endpoint so it will populate a new event
My javascript is really not strong. Ive been constructing a tool in Go and it's like 99% complete and finding FullCalendar was a godsend for displaying data. I've got it all setup and selection works ...
2
votes
1
answer
389
views
How to combine AbortController and AbortSignal?
To specify a timeout of a fetch request, we can use a AbortSignal.timeout() signal:
await fetch(url, {
signal: AbortSignal.timeout(10 * 1000),
});
But this is just a standalone signal, not a ...
1
vote
0
answers
59
views
JavaScript `fetch()` won't post data in Django
The issue is encountered in the framework of Django. The related code lines are described below.
These are the HTML lines, in which, the first div and the nested p will be filled with other HTML ...
0
votes
0
answers
85
views
Chrome extension fetch to GoHighLevel API returns 401 Unauthorized despite correct Bearer token
I'm building a Chrome extension that calls the GoHighLevel (GHL) API to create and manage contacts. When I do the same request in Postman using my GHL API key as a bearer token, it works (status 200). ...
1
vote
1
answer
102
views
How to handle for a request that takes to long to download content using useQuery from React Query?
I'm using useQuery function from React Query to fetch data in my React application. However, I'm encountering an issue where some requests take too long to download content (about a minute).
Here's a ...
-1
votes
1
answer
65
views
Unable to fetch and Display HTML Content from Public Directory
Need help with Vite + React, where one is unable to fetch and display content from the public directory. Despite following various troubleshooting steps, the content from the projects home.html is not ...
0
votes
1
answer
106
views
Does my .htaccess configuration also affect my internal fetch API calls?
I have a website composed of PHP files, so I have the following configuration within my .htaccess file to hide the ".php" extension from my URLs:
.htaccess configuration
RewriteEngine on
...
1
vote
0
answers
52
views
Possible to send custom header from the browser when loading images/videos?
When calling fetch("http://server.com/api) we can send custom headers, like "authorization".
But when including images, videos, or other things in the HTML, there is no control over the ...
1
vote
1
answer
932
views
Why do I need AbortSignal when using the resource API of angular. What is it's use?
I have been defining resource as follows:
resource: ResourceRef<any> = resource<ResourceRequest | undefined, any>({
request: (): ResourceRequest | undefined => {
return {
id:...