Discussions
axios.post giving a 400 status error
about 1 month ago by Vasvi Sood
I am trying to upload the data from my react app using the pinata API. The code is given below:
try {
const data = JSON.stringify({
pinataContent: {
name: "Pinnie NFT",
description: "A nice NFT of Pinnie the Pinata",
external_url: "https://pinata.cloud",
image:
"ipfs://bafkreih5aznjvttude6c3wbvqeebb6rlx5wkbzyppv7garjiubll2ceym4",
},
pinataMetadata: {
name: "metadata.json",
},
});
const res = await axios.post(
"https://api.pinata.cloud/pinning/pinJSONToIPFS",
data,
{
headers: {
"Content-Type": "application/json",
Authorization: JWT,
},
}
);
console.log(res.data);
};
} catch (error) {
console.log(error);
}
It gives the error: xiosError {message: 'Request failed with status code 400', name: 'AxiosError', code: 'ERR_BAD_REQUEST', config: {…}, request: XMLHttpRequest, …}
Why am I getting this error?