Comments (9)
Hi @spacedragon
The problem was that the fetch implementation wasn't sending the real FormData object to the server causing the server to recieve a string of "[Object object]".
This is now fixed along with a new test case that checks this functionality keeps working.
Will appreciate if you could try it out and see if it fixed your version by installing xhook with the latest commit hash: 93879b7
If you are using npm it should look like this in your package.json:
{
"dependencies": {
"xhook": "jpillora/xhook#93879b7"
}
}
from xhook.
close since nobody care.
from xhook.
Hi @spacedragon,
There is no reason to get upset, you have to remember that we are people who are working on open source on our free time and don't always have time to reply because of "life".
I have just came back from a 1 month vacation, where I had no access to a computer so it's really not that we don't care about your issue but we might be just busy.
Now let's talk about the issue, you say that form data is missing from fetch, how do you know it's missing? Did you check it on the request or in the chrome dev tools?
Can you post a small example where this isn't working or post more data on how you tested it and which hooks and operations in those hooks you used so we can further debug it?
Please note that if you found out the form data is missing using the Chrome devtools, it is a bug in Google Chrome which I opened an issue for and should be fixed hopefully in the near future.
Here is the bug report if you wish to track it and see when it's fixed:
https://bugs.chromium.org/p/chromium/issues/detail?id=698209
Thanks for reporting the bug and helping us improve!
from xhook.
Hi @spacedragon
Unfortunately I'm not able to reproduce this issue so unless you can provide more info or a failing examples I'll have to close this issue.
Please let me know if this is still relevant so we can try to resolve this issue.
Thanks
from xhook.
try the following code;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form>
<input type="text" id="username" name="username">
<input type="password" id="password" name="password">
<button id="submit" type="button">submit</button>
</form>
<pre id="two"></pre>
<!--<script src="./xhook.js"></script>-->
<script type="text/javascript">
/*xhook.after(function (request, response) {
console.log(request, response)
});*/
document.getElementById("submit").addEventListener("click", function () {
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
const data = new FormData();
data.append('username', username);
data.append('password', password);
console.log("submitting data,", data);
fetch(`authenticate/`, {
method: 'POST',
credentials: 'same-origin',
body: data
});
});
</script>
</body>
</html>
-
I don't think it's relevant to chrome dev tools, since we found this problem because of our servers can't receive any valid request.
from xhook.
Ok, I am able to reproduce the issue. It looks like the request parameters turn in [Object object] instead of the correct payload.
I do want to mention though that testing this using the chrome dev tools currently isn't possible because of the bug I mentioned which was confirmed by the chromium team.
I reproduced the issue with Firefox and will start looking into it
from xhook.
Fixed in 1.4.5
from xhook.
I'm finding this issue when using 1.4.5 and 1.4.9. It may be an environmental thing or something specific to my package code, but it's the same symptom of the body FormData getting wiped out and showing [Object object] instead. It's odd that I would find this issue in later revisions. I've confirmed that the xhook node_module folder I have is actually built with 1.4.9 and contains code from 93879b7
The weirdest part is that this is happening for me despite using the native window fetch by capturing it from xhook.fetch
from xhook.
Just verifying, I'm still encountering this.
from xhook.
Related Issues (20)
- Warning 'Event.path' is deprecated and will be removed in M109, around January 2023. Please use 'Event.composedPath()' instead HOT 1
- Slowing down the network calls HOT 2
- Errors are passed to Promise.resolve instead of Promise.reject with xhook 1.4.9 HOT 6
- Automate release process HOT 10
- Speed up tests
- Some files are unnecessary. HOT 1
- Automatic Github releases using conventional commits
- xhook breaks `navigator.sendBeacon(url, formData)` HOT 6
- Change the output of xhook in src/main.js HOT 1
- FormData fails all calls - testing solution but can't make it work at all HOT 17
- Before handlers for fetch(new Request('/foo')) requests : 1) sync handlers get no information; 2) sync and async can't change request parameters or replace the Request instance.
- When other programs modify XMLHttpRequest.prototype., xhook will not work HOT 1
- [Question] How to skip certain URL (some URL use mock data and some still go to real API )? HOT 1
- When you use xhr.response to read response data, the hook becomes invalid
- [Bug] Unable to retrieve the requested URL in the response
- The HTTP field name should be lowercase
- [Bug] The default value of XHR's response is incorrect
- [Bug] isFetch parameter is undefined
- Header parsing fails since it assume CRLF is always present, in my scenario only LR present
- facade is missing responseType, but some clients expect to see it HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xhook.