Importing data from a json file

Hello everyone !
Newbie question

Iā€™m building a website with Next.js and DatoCMS

I want to import a huge list of items from a json file into datocms models

I have read Import and export content - Importing data from external sources - DatoCMS Docs
However I am quite unsure where I should put the code ?
Also worth mentioning I want to import the file only once, not on every build

Looking for guidance !

Hello @alexis.doroszkiewicz, and welcome to the community!

The code mentioned in the link you sent is supposed to be on a NodeJS script, that will be run once through your terminal to do the import through your local machine that houses the JSONs.

The article you linked goes through the steps to take while generating this script, as making sure your dato models fit your JSON data, creating the requests on your script that loop through the JSON and create the records based on the Data, and so on.

Let me know if you have any problems during the steps so i can solve any doubts regarding the script or regarding the API interactions that you may have :slight_smile:

1 Like

Thank you so much for the lightning fast answer !

I will try what you mentioned and will come back to you if i need further guidance :slight_smile:

Much appreciated !

1 Like