![]() Now, we need to install a few things to get going, namely: cd ~/ some / file / path / api - server npm init So, let's create a new folder and navigate into it:ĭrop into the folder and run NPM's init script to set up the project with some default files, such as package.json. Node API server setupįirst things first, you'll need to make sure you have Node.js installed on your machine and preferably an up to date version of NPM. ![]() What's more, I wanted to serve and edit real data from physical JSON files as a simple filestore database – this would save a lot of faff involving MongoDB or SQL Lite both great, but overkill for this job.įor crying out loud, shouldn't it be easy to just make a Node API server that saves data to JSON files?!Īfter what felt like a decade of rummaging through complex documentation and hundreds of StackOverflow answers, I found a brilliant article by Nic Raboy from as long ago as 2015! I think the article misses out a few of the necessary 'real world' end points such as POST that actually interact with a real datastore - in this case, JSON files.īut enough preamble, let's do this thing! Strap in, it's gonna be a long one!! 1. Driven by a recent need to create a local API server to provide me some data-serving end points to a React app, I ran into a few huge walls.Īlthough there are a lot of articles out there detailing how to create a Node API server locally, some don't cover enough ground (especially from examples of how to use) or are overly complex.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |