This simple project is for developer who want to create an mock api quickly for testing usage. In this demo, we will be looking at how to deploy your cool NodeJS app to Heroku. By the end of this demo, we will have a API Endpoint app running on a public domain that can be accessed by anyone.
- Go to Heroku and sign up(https://signup.heroku.com/) an account
- In this page, click
Fork
on the top right corner to clone a copy - Click
deploy button
to create application - Click
Manage
and Connect Github to Heroku
- Open Deploy tab and scroll to the
Deployment method
section - Select GitHub as the method
- It will show a
Connect to GitHub
option where we can provide our GitHub repositoryApi-Endpoint
. If you are doing it for the first time, Heroku will ask permission to access your GitHub account. - Enable
Auto Deploy
button if you want Heroku detect your github data and upload to Heroku automatically
- All done! Click
View
to see how's going on. Now you can editServer.js
for further usage based on your requirement
https://king-api-endpoint.herokuapp.com/api-endpoint
var jsonContent = {
title: "title",
imageUrl: "https://image.flaticon.com/icons/png/512/61/61456.png",
contact: [ {id: 12345, name: "King Lai"},{id: 12346, name: "King Lai"}],
show: true
};
https://king-api-endpoint.herokuapp.com/api-endpoint-parameter?title=King
var titleRequest = request.query.title; // Change .title / .name or any text based on your parameter name
var jsonContent = {
title: titleRequest,
imageUrl: "https://image.flaticon.com/icons/png/512/61/61456.png",
contact: [ {id: 12345, name: "King Lai"},{id: 12346, name: "King Lai"}],
show: true
};