Way to make updates in bulk, for one specific fiel on each specific content-type

Literally just a for loop or a .forEach():

const axios = require("axios");

const strapiURL = "http://localhost:1337/articles";

const data = [
  {
    title: "test1",
    body: "test1",
  },
  {
    title: "test2",
    body: "test2",
  },
  {
    title: "test3",
    body: "test3",
  },
  {
    title: "test4",
    body: "test4",
  },
];

async function sendData(data) {
  for (let i = 0; i < data.length; i++) {
    try {
      await axios.post(strapiURL, data[i]);
    } catch (e) {
      console.log(e);
    }
  }
}

sendData(data);

1 Like