hai i have json file in my local how can add that file data into the ember application
1 Like
Hai velugu,
- Serve that json file through a web server (you can run
python -m SimpleHTTPServer 8000
in that directory) so that you can access something likehttp://localhost:8000/file.json
- Alternatively, load your json in this simple node.js server: Quickest Backend API for Ember - Ember Igniter
- Override your application adapter to point to whatever backend you chose
- Load your models through your routes’
model()
hooks
1 Like
Hai Velugu,
I’m not sure what you’re trying to do exactly because you haven’t explained it clearly in your question. If you just want to access a .json
file in your Ember app, you can use Express in /server/mocks/your-things.js
to mock a response when your app hits the app/v1/my-things
endpoint.
/*jshint node:true*/
module.exports = function(app) {
var express = require('express');
var myThingsRouter = express.Router();
var fs = require('fs');
var myThings = JSON.parse(
fs.readFileSync('./app/mocks/fixtures/things.json')
);
myThingsRouter.get('/', function(req, res) {
res.send(myThings);
});
app.use('/api/v1/my-things'), myThingsRouter);
};
1 Like