1

this is my index.html i'm unable to get output while running npm start in the command prompt i have tried using localost:8080 and localhost:8080/index.html but the only output i'm getting is cannot get

<!DOCTYPE html>
<html lang="en">
<head>
 <script src="Scripts/angular.min.js"></script>

 <script src="Scripts/app.js"></script>

 <script src="/Scripts/angular/angular.js"></script>
</head>
<body ng-app="myApp">    
  <div ng-controller="myCtrl">
    <form>
      Author:
     <input type="text" ng-model="author">
     <br>
     <br> Title:
     <input type="text" ng-model="title">
     <br>
     <br> Body:
     <input type="author" ng-model="body">
     <br>
     <br>
     <input type="submit" value="Submit" ng-click="submit()">
     </form>
 </div>
</body>
</html>

this is my app.js file

i'm unable to get output while running npm start in the command prompt i have tried using localost:8080 and localhost:8080/index.html but the only output i'm getting is cannot get

var app = angular.module('myApp', []);

app.controller('myCtrl', function($scope) {

$scope.submit= function(){

  var data = $.param({

    book: JSON.stringify({

        author: $scope.author,
        title : $scope.title,
        body : $scope.body
    })
  });

  $http.post("/api/book/", data).success(function(data, status) {
    console.log('Data posted successfully');
  })
}
});

This is server.js file

i'm unable to get output while running npm start in the command prompt i have tried using localost:8080 and localhost:8080/index.html but the only output i'm getting is cannot get

var express = require('express'); 
var mysql = require('mysql');
var app = express();

var connection = mysql.createConnection({
 host: 'localhost',
 user: 'root',
 password: '',
 database: 'mydb'
});
connection.connect();

app.post('/api/book', function(req, res, next){
var cope = req.body.params;
var query = connection.query('insert into cope set ?', cope,  function(err,   result) {
 if (err) {
   console.error(err);
   return res.send(err);
 } else {
   return res.send('Ok');
 }
});
});
app.listen(8080);
console.log("listening");
6
  • you have to create route for that. Commented Feb 16, 2018 at 16:18
  • please explain me in detail @RahulSharma Commented Feb 16, 2018 at 16:20
  • Happy to see, you used it :) stackoverflow.com/questions/35699095/… Commented Feb 16, 2018 at 16:27
  • even i have done what u said i'm getting same error Commented Feb 16, 2018 at 16:30
  • What is the error. Where do you see the error? Commented Feb 16, 2018 at 16:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.