How to export API request to mysql mariadb

Hi, I have an API query and there I get the data in an array {{['0'] }}, in the array data.Data are the objects 0,1,2,3 etc., and there are all the order information, order number, invoice number, address, ordered items, etc.

I want to transfer this data into my SQL database. I manage to transfer each column from the object 0 or 1 individually via the GUI mode, but not the complete array.

Especially because the individual orders are structured like this:

  • SKU
  • Buyer
  • CreatedAt
  • Customer
    -- Name
    -- Street
    -- E-mail
  • CustomerNumber
  • Comments

The object in the object causes a {{ second row content }} when queried, resulting in an error in the mariadb.

Can someone give me a hint how to get a solution?

Hi @Konstantin_Kiss Does your database have a separate column for the customer name, customer email, etc?

Are you looking to flatten the api data so that none of it is nested in an array/obj? If so, you could try a flatten strategy like this. You may need to modify the code for your specific column names. Similarly, it sounds like you'll need to modify the mode to check for nested arrays as well.

Something like this could be added to flatten nested arrays of objects:

           else if((typeof ob[i]) === 'object' && Array.isArray(ob[i])){
            const temp = flattenObj(ob[i]);
            for (const j in temp) {
                // Store temp in result
                result[i + '.' + j] = temp[j];

I have now solved it differently and get the data individually from the object:

let customerEmail = item.Customer.Email;
let customerName = item.Customer.Name;
let customerNumber = item.Customer.Number;
let customerTel1 = item.Customer.Tel1;

1 Like