I am a beginner in angular 2 and I have this script that I need to integrate in an angular2 project to fetch some data from odoo :
const Odoo = require('odoo-connect');
const odoo = new Odoo({
host: 'demo',
port: 80
});
var project_list = [];
odoo.connect({
database: 'database',
username: 'admin',
password: 'admin'
})
.then(client => {
return client.call('project.project', 'search_read', [], {});
})
.then(projects => {
for (var i = 0; i < projects.length; i++) {
var project = projects[i];
project_list.push(project['name'])
}
console.log(project_list);
});
I just want to display the data in one simple page just to test it , before including it in the main project.I tried to build a trial project with Angular-CLI and for app.component.ts :
import {Component } from '@angular/core';
import { OnInit } from '@angular/core';
import { Input } from '@angular/core';
import * as connect from 'odoo-connect';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent implements OnInit{
private host:string;
private port:number;
@Input() project_list;
constructor(){
this.host='demo';
this.port=80;
}
ngOnInit(){
let project_list : Array<any> = [];
const odoo = new connect({
host: 'demo9',
port: 80
});
odoo.connect({
database: 'database',
username: 'admin',
password: 'admin'
})
.then((client:any) => {
return client.call('project.project', 'search_read', [], {});
})
.then((projects:any) => {
for (let i = 0; i < projects.length; i++) {
let project = projects[i];
project_list.push(project['name'])
}
console.log(project_list);
})
}}
I get this in my console : webpack: Compiled successfully , but in the browserconsole I get this : Uncaught TypeError: Cannot read property 'prototype' of undefined