Hey guys, i’m at the networking section and when i try to post a listing to my sever the result is always wrong… btw i didn’t implement location. Here is the handleSubmit from my code:
const handleSubmit = async (listing) => {
const result = await listingsApi.addListings(listing);
if (!result.ok) return alert('Error');
alert('Success');
};
I’m not sure if the problem is there or somewhere else, maybe the course it’s outdated which i don’t belive. Any comment would be excelent, hope to get some help.
When you this, reload the app and confirm the status code returned (towards the end of object echoed on the terminal). When you do let me know. There is every chance that you are not passing the request header, “x-auth-token”.
@Avivf , the result I am getting looks identical to yours. I’ve seen else where people suggest trying to run it with debugger mode turned off. That solution did not work for me but maybe its worth trying.
@Avivf Try specifying the content type in the post call, that seemed to work for me. This is what I’m returning from addListing: return client.post(endpoint, data, { headers: {'Content-Type': 'multipart/form-data'}, });
But like I mentioned before, I still get an error when I try running in debugger mode with Network Inspect enabled