Tag: angular http

将多个AngularJS Post请求发送到Express服务器? 服务器崩溃的第二个post请求

所以鉴于我不能同时在我的客户端运行这两个post请求,我试图在第一篇文章的.then部分运行第二篇文章。 这对我的其他项目一直工作得很好。 但由于某种原因,当第二个职位请求触发我的服务器不答复。 当我检查服务器的控制台时,我发现它崩溃,并有一个错误消息(在这篇文章的底部)。 什么可能导致这个? 我已经在我的服务器代码中的第二个发布请求中放置了断点,并且注意到断点甚至没有被触发。 服务器在命中之前崩溃,并让我select继续。 客户端代码(当用户按下button时被触发): $scope.searchCharacter = function(){ var request = {name: $scope.charName, realm: $scope.selectedRealm}; //First post request $http.post('/searchCharacter', request) .then(function(response) { //sets some variables var id = 0; //Second post request $http.post('/helloworld', id) .then(function(response) { //sets some more variables debugger; }); }); } 服务器代码: //First post request app.post('/searchCharacter', jsonParser, function (req, […]

$ http获得的返回值不同于$ resource get

我正在尝试使用User $resource下载用户报告。 但是,返回的结果是这样的对象:(奇怪) {0: "n", 1: "a", 2: "m", 3: "e", 4: ",", 5: "e", 6: "m", 7: "a", 8: "i", 9: "l", 10: ",", 11: "p", 12: "a", 13: "r", 14: "t", 15: "n", 16: "e", 17: "r", 18: ",", 19: "r", 20: "o", 21: "l", 22: "e", 23: ",", 24: "p", 25: "h", […]

与前端和后端的错误沟通(Java – Angular)

我尝试使用Java / Spring Boot后端来交stream我的Angular Frontend。 但terminal显示我这个错误: [HPM]尝试从localhost:4500代理请求/ api / dados时发生错误:http:/ localhost:8080(ECONNREFUSED)( https://nodejs.org/api/errors.html#errors_common_system_errors ) 这是我的exemple.service.ts(Angular)代码。 在这里我请求数据: import {Injectable} from "@angular/core"; import {Http, Response} from "@angular/http"; import 'rxjs/Rx'; @Injectable() export class ExService{ constructor(private http: Http){ } getName(){ return this.http.get("/api/dados").map( (response: Response) =>{ return response.json(); } ); } } 这里是我的exemple.java(Java代码)。 它负责发送数据: package com.lucas.bef.Envia; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import […]

发送$ http.get两次

编辑1:伙计们,我注意到我在我的authentication工厂调用$ http.get('/ posts')(用于某些特殊用途)。 对不起,这个愚蠢的问题。 当赏金结束时我会删除它。 我有以下代码来加载页面https://localhost:3000/#/home ,它从数据库中获取所有post并显示它们。 问题是,我意识到日志router.get /posts是打印两次,而here和there只提醒一次。 有谁知道这是否意味着$http.get被执行两次? 如果是的话,问题在哪里? app.config(… …) { $stateProvider .state('global', { templateUrl: '/htmls/global.html', controller: 'GlobalCtrl' }) .state('global.home', { url: '/home', templateUrl: '/htmls/home.html', controller: 'MainCtrl', resolve: { postPromise: ['posts', function (posts) { return posts.getAll(); }] } }); }]); app.factory('posts', ['$http', 'auth', function ($http, auth) { var o = { posts: […]