Create a Node.js function for an HTTP GET request for a Swagger API

InstructorWill Button

Share this video with your friends

Send Tweet

This lesson will teach you how to create the javascript functions defined by the Swagger specification to return all Todo items to the client when requested with an HTTP GET method.

Victor Hazbun
~ 7 years ago

I have no idea how to test this episode because I do not have a database on my Elasticsearch installation. I'm running on OS X Sierra, but I do not know how to create an Elasticsearch DB or tables. Can you please guide me?

Victor Hazbun
~ 7 years ago

How do you have access to the es.js file functions if you are not exporting them? I'm getting:

{
  "message": "client.search is not a function"
}
Will Buttoninstructor
~ 7 years ago

Thanks for posting! I'm creating a git repo that will setup Elasticsearch and the sample data for you. I'll have it uploaded and post it here in the next few hours.

Will Buttoninstructor
~ 7 years ago

Try this out and let me know if it helps: I updated the repo to include a docker container with Elasticsearch and a utility to import the sample data into Elasticsearch. Detail on usage can be found here: https://github.com/rekibnikufesin/nodejs-api-swagger/tree/master#running-elasticsearch-and-sample-data You'll need docker installed, but everything else should be included.

steve
~ 7 years ago

I am really glad you did this, but some film editing for would be also be beneficial.

Will Buttoninstructor
~ 7 years ago

Thanks for the feedback, Steve. Hearing what is done well and what could be improved helps me create better lessons over time. What editing is needed? Adding the installation steps to the lesson?

Larry Botha
~ 6 years ago

Ye, the ElasticSearch dep comes as a surprise.

In this video we're introduced to a new dependency which many of us don't have the means to evaluate without working out how to install, configure, and most likely debug to get running. What starts as a 5 minute video could end up being a 1+ hour effort in frustration for unfamiliar learners. With that said, thanks for the repo with the Docker container!

I'd evaluate how the lesson could be reduced to the most fundamental dependencies while still effectively demonstrating the intention of the lesson. Should the learner install MongoDb? There's a little bit of setup there, but there are more people familiar with Mongo than ElasticSearch. How about a json file? Zero setup sounds cool. Would a readFile be sufficient to demonstrate an asynchronous request to an endpoint? Does it benefit the learner to explain how to extract the data out of a deeply nested ElasticSearch's response object when a simpler object may do the same job?

I'm doing this course because I'm unfamiliar with Swagger, and want to learn how to use it to bolster my capabilities to build APIs - adding ElasticSearch makes me think "geez, I already don't know these other things, now there's a non-trivial search engine that I know even less about!"

This is a great series, but this lesson comes with a few surprises. I by no means want to diminish the hard work you've put into the course, just provide a perspective on what a noob may experience :)

Royston Shufflebotham
~ 6 years ago

I'm all but ready to give up. I was following along with the course fine up to this point, but then it all grinds to a halt:

At 02:00, the video jumps from the es.js file to another file, missing out the vital export line that makes it work.

At 03:26 I realise that I need an entire separate elasticsearch service installed and configured, with data loaded into it.

There are instructions in the comments here to get a docker container up and running to do that, but they don't currently work. (I've raised an issue.)

It would have been nice to have a Swagger tutorial that didn't require spending a load of effort setting up other technologies. I can't help but think that just reading some data from a flat file, or hardcoding a bit of data in the js files would have served to demonstrate Swagger just fine without requiring external services to be installed and configured. As is, it's hugely distracting from actually learning about Swagger.

Jonathan Palma
~ 5 years ago

If someone is receiving an "ERROR: manifest for elasticsearch:latest not found" In file: docker-compose.yml Line 4: image: elasticsearch:7.4.2 Line 14: image: kibana:7.4.2 https://hub.docker.com//elasticsearch https://hub.docker.com//kibana IDK if is a good idea change for the current versions or look forward the versions of the video I put the current version and I'm seeing stuff in the terminal

Jonathan Palma
~ 5 years ago

Hello changing docker-compose.yml line: 4: image: elasticsearch:5.6.16 line 14: image: kibana:5.6.16

Looks that at least Kibana is showing something in the browser after the docker-compose and visiting http://localhost:5601/