BenedictaUche / contentful-csv-import

A JavaScript example to show how to import a CSV file into Contentful via the CMA

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to import a CSV file into Contentful as entries using the Contentful Content Management API and JavaScript

This currently assumes your content type is already set up and ready to import entries.

Install dependencies

npm i

Add your Contentful credentials.

Add a credentials.js file at the root of the project with the following:

module.exports.CMA_TOKEN = "your_cma_token;
module.exports.SPACE_ID = "your_space_id";

To run this script, navigate to the project root and run:

node index.js

The script will perform the following actions:

  1. Read the contents of ./resources/animals.csv
  2. Convert the contents of the csv file to an array of JavaScript objects
  3. Connect to a Contentful space and get a list of environments
  4. Check for an experimental environment and delete and recreate one as necessary
  5. For each item in the array, create a new 'animal' entry
  6. Publish the entries

About

A JavaScript example to show how to import a CSV file into Contentful via the CMA

License:MIT License


Languages

Language:JavaScript 100.0%