learn-co-curriculum / phase-1-sending-data-with-fetch Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
https://my.learn.co/courses/590/assignments/27782?module_item_id=68707
I've solved the assignment, but for some reason I still get an error. I don't think the error is related to the code I've written but more the test or something in node-fetch
package has change maybe?
Here is the error:
npm test
> [email protected] test
> mocha --timeout 5000 -R mocha-multi --reporter-options spec=-,json=.results.json
submitData()
(node:1083030) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
(Use `node --trace-deprecation ...` to show where the warning was created)
1) makes a POST request to /users with a name and email
✓ makes a POST request to /users with a name and email
✓ handles a failed POST request using catch, appends the error message to the DOM
✓ handles a failed POST request using catch, appends the error message to the DOM
3 passing (301ms)
1 failing
1) submitData()
makes a POST request to /users with a name and email:
Uncaught TypeError [ERR_INVALID_ARG_TYPE]: The "stream" argument must be an instance of Stream. Received an instance of Socket
at new NodeError (node:internal/errors:393:5)
at eos (node:internal/streams/end-of-stream:65:11)
at IncomingMessage._destroy (node:_http_incoming:234:21)
at _destroy (node:internal/streams/destroy:109:10)
at IncomingMessage.destroy (node:internal/streams/destroy:71:5)
at endReadableNT (node:internal/streams/readable:1375:16)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
This is after writing my code and running npm install
then npm test
.
Here is my code:
const submitData = (username, email) => {
const formData = {
name: username,
email: email
};
const configurationObject = {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify(formData)
};
const destinationURL = "http://localhost:3000/users";
return fetch(destinationURL, configurationObject)
.then(response => response.json())
.then(object => document.body.innerHTML = object["id"])
.catch(error => document.body.innerHTML = error.message);
}
node version: v19.0.0
No response
https://learning.flatironschool.com/courses/5185/assignments/179314?module_item_id=396190
Missing the word 'us' in the following:
It also enables to improve our users' experience by rendering content without reloading the page.
No response
Instead of this:
It also enables to improve our users' experience by rendering content without reloading the page.
Maybe this:
It also enables us to improve our users' experience by rendering content without reloading the page.
One code screenshot in the phase-1 Sending Data with Fetch lesson on Canvas needs to be corrected. Currently, the screenshot shows the "Accept" header without quotation marks. See attached link for the lesson and the code screenshot.
Canvas Lesson:
https://learning.flatironschool.com/courses/4978/assignments/167598?module_item_id=362221
Code Screenshot:
https://learning.flatironschool.com/courses/5185/assignments/179314?module_item_id=396190
This sentence seems more complex than necessary, maybe because of passive voice?
Servers may reject requests without the specific headers the server is configured to expect.
Mentally processing this logic seems like unnecessary overhead for comprehending this message.
No response
Instead of this:
Servers may reject requests without the specific headers the server is configured to expect.
Maybe this?:
A server that expects specific headers may reject requests that omit those headers.
Or: ... that don't include those headers.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.