Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 将GET从节点API存储到角度服务_Node.js_Angular_Api - Fatal编程技术网

Node.js 将GET从节点API存储到角度服务

Node.js 将GET从节点API存储到角度服务,node.js,angular,api,Node.js,Angular,Api,我很抱歉,如果已经有人问过这个问题,我已经浏览了大量的帖子和文档,但是没有什么听起来像我正在尝试做的,即使我认为这很简单 我正在构建一个小小的网络应用程序。它有两个目录:api(节点,处理:8080)和app(角度,处理:4200)。他们分开工作的很好,我的数据库已经准备好了,一切都很好。由于Json代理(我不使用CORS),我的API路由在我的Angular应用程序中工作,例如: localhost:4200/api/users URL将获取所有我的用户,没有问题。我原以为我已经完成了最难的部

我很抱歉,如果已经有人问过这个问题,我已经浏览了大量的帖子和文档,但是没有什么听起来像我正在尝试做的,即使我认为这很简单

我正在构建一个小小的网络应用程序。它有两个目录:api(节点,处理:8080)和app(角度,处理:4200)。他们分开工作的很好,我的数据库已经准备好了,一切都很好。由于Json代理(我不使用CORS),我的API路由在我的Angular应用程序中工作,例如:

localhost:4200/api/users URL将获取所有我的用户,没有问题。我原以为我已经完成了最难的部分,但现在我陷入了一件简单的事情:我该如何在TypeScript中为我的角度服务使用这些API路由呢。比如,通过这个服务,我想操作已经可以从localhost:4200/api/users访问的数据。没别的了。如何在代码中使用/调用此URL/路由


在这件事上没有医生让我很困惑,对我来说这是一件很基本的事情。如果有人能给我指出正确的方向,我会很高兴的。非常感谢

角度和节点路径不同。localhost:4200/api/users

//服务

callapifunction(name: string, pass: string, confirmPass: string): Observable<any> {
  const body = new HttpParams()
      .set('username', name)
      .set('password', pass)

  return this.http.post(
      `localhsot:8080/api/users`,
      body
  )
      .pipe(
          tap(_ => console.log(_)),
          catchError(this.handleError<any>('verify'))
      );
}

你检查过HTTP文档了吗?
import {Route} from '@angular/router';
import { HomeComponent } from './home/home.component';
export const routerConfig: Route[] = [
    {
        path: '',
        children:[
            //admin
            {
                path: 'api/users',
                component: DashboardComponent
            },
            {
                path: 'main/login',
                component: LoginComponent
            },

        ]},

    {
        path: '**',
        redirectTo: '/'
    }
];