[SOLVED] Axios 500 error on localhost:3000 for uploadFolder

I am trying to use uploadFolder api, though its working with my own API key in the documentation, but doesn’t work on localhost:3000 or 127.0.0.1:3000. The axios throw 500 error 1. Error: Request to bg page ([object Object]) rejected by timeout

This is the code:

`
const save = async () => {
const options = {
method: “POST”,
url: “https://deep-index.moralis.io/api/v2/ipfs/uploadFolder”,
headers: {
accept: “application/json”,
“content-type”: “application/json”,
“X-API-Key”: ‘’
},

  data: [{ path: "post.json", content: "YXNkZg=="}],
};

await axios
  .request(options)
  .then(function (response) {
    console.log(response.data);
  })
  .catch(function (error) {
    console.error(error.response);
  });

};
`

What is the content or data you’re uploading (or what works when done through the documentation)?

Can you post your full code (including options)? Which version of axios are you using?

Also please make sure to post as code.

The data mentioned is the content I am posting on both localhost and documentation. The options would be path: Post.json and content: “YXNkZg==”. The axios is latest version : 1.1.2

Changing content-type to Content-Type works on my end with [email protected]:

const options = {
  method: 'POST',
  url: 'https://deep-index.moralis.io/api/v2/ipfs/uploadFolder',
  headers: {
    accept: 'application/json',
    'Content-Type': 'application/json',
    'X-API-Key': 'test',
  },
  data: [{ path: 'post.json', content: 'YXNkZg==' }],
};

axios
  .request(options)
  .then(function (response) {
    console.log(response.data);
  })
  .catch(function (error) {
    console.error(error);
  });

content-type works on older versions e.g. 0.27.2.

Wow, thanks it worked. <3

1 Like