Can't post data (Networking section)

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.

Hi meister,

Your handleSubmit looks ok. One way to debug the code above is to log the error on the terminal. Kindly update the line:

if(!result.ok) return alert(‘Error’);

to:

if(!result.ok) {
console.log(result);
alert(‘Error’);
return;
}

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”.

Cheers,
Seun O.

Hey olowoseun i have the same error can you help me?

yarn add joi@14 solved my problem that problem happens because joi.validate is no longer supported