I've been working on a small Angular2 application using Typescript and things have been going smoothly so far.
My goal is to utilize a file called config that contains all the necessary settings for the application. Here's the file in question:
ConfigObject.js
export var ConfigObject = {
apiVersion : 'v1/',
productBox : 'http://localhost:8931/api/'
};
I've been trying to import this file into a service to access some of the settings, but I keep getting an error saying the file cannot be found.
Here's my service:
import { Component, Injectable } from 'angular2/core';
import { Http, Response } from 'angular2/http';
import 'rxjs/add/operator/map';
import { ConfigObject } from '../../ConfigObject';
import { PRODUCTS } from '../data-stores/mock-products';
@Injectable()
export class ProductService {
constructor(private http: Http) {
}
private APIUrl = ConfigObject.apiVersion;
getHeroes() {
return Promise.resolve(PRODUCTS);
}
getHeroesSlowly() {
/*return new Promise<Hero[]>(function(resolve) {
setTimeout(function() {
return resolve(HEROES);
}, 2000)
});*/
// The below is the new fat arrow version of the above
/*return new Promise<Hero[]>(resolve =>
setTimeout(() => resolve(HEROES), 2000)
);*/
}
}
The ConfigObject file is located at the root of the application, two folders up. However, when I try to start the application, I receive the following errors in the console:
GET http://localhost:3000/ConfigObject 404 (Not Found)
I'm puzzled as to why this is happening. Any help would be greatly appreciated!
Thanks!