I know it’s not a required field but I need to link the user with the saved data to show it in the main application.
This is how I used to POST with no errors
export async function addAddressApi(auth, address) {
try {
const url = `${API_URL}/addresses`;
const params = {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${auth.token}`,
},
body: JSON.stringify({
data: address,
}),
};
const response = await fetch(url, params);
const result = await response.json();
return result;
} catch (error) {
console.log(error);
return null;
}
}
Here is an example printing the sent data
Object {
"address": "Cnnxnx",
"city": "Fncnc",
"district": "Cncncn",
"name_lastname": "Fndnc",
"phone": "5998986",
"reference": "Xncn",
"title": "Fjd",
"user": 1,
}
Also this is my collection
