Search Posts

Category: post

Angular.js can’t make a POST request with image

Hello everyone I am struggling with a simple event. I truly lost in problem and can’t figure out what real problem is. I have a service which you can make a POST request with your image and get a image as response it is working fine when I test it on postman. Here is working postman code (taken from postman code generator for Javascript Jquery AJAX) var form = new FormData(); form.append(“image”, “C:wamp64wwwProjelerppoguz.jpg”); form.append(“flag_id”, “1”); […]

IBM WATSON Angularjs 1 POST Request Issue ( 401 (Unauthorized) )

I’m Trying to work on NLU of IBM WATSON Via POST API Request using AngularJS 1, Here is my code , Where giving 401 (Unauthorized) as response. $scope.textcontent=”Something”; var auth =window.btoa(‘XXXXXXX:XXXXXX’); var headersa = {“Authorization”: “Basic ” +auth, ‘Content-Type’: ‘application/json’, ‘version’:’2018-03-16′ }; console.log(headersa); $“”+$scope.textcontent+”&features=concepts,categories,emotion,entities,keywords,relations,semantic_roles,sentiment”,{headers: headersa}).then(function (res){ $scope.response =; console.log(“IBM WATSON “+res); console.log(“IBM WATSON “+$scope.response); }); Source: AngularJS

$http – post – Bad request error not handled (undefined)

I am trying to do a POST to create an account and I am expecting a 400 Bad Request (Username already used or Email already used). I have confirmed with other tools (RESTED for firefox) that I am receiving the correct 400 Error with my message, but with AngularJS response.status, and response.statusText all give an ‘undefined’ value. Below is the definition of my request in AngularJS: var req = { method: ‘POST’, url: myURL, […]

Difficulty performing POST – Mean Stack

When I pass an undefined value I get a return, however when I pass a non undefined value, I get bad request (400) error. My code: Factory angularjs: function ApiExterna($http, consts) { function buscarCep(cep) { //cep is a string $‘http://localhost:3003/api/buscarCep’, cep) .then(resp => { console.log(resp) return null }).catch(function (resp) { ) } return { buscarCep } } Backend route: const express = require(‘express’) const auth = require(‘./auth’) module.exports = function(server) { const protectedApi = express.Router() […]

Combine JSON for two POST in AngularJS

I am trying to combine response of one POST data with another input JSON so that it can do another POST function. Controller 1:- $scope.master = {}; $scope.addChild = function(net) { $scope.master = angular.copy(net); $“url”,$scope.master).then( function(data) { $scope.childData = data; $scope.dataName = $scope.master.Name; growl.success(“Created a new Child”); console.log(data); },function (data, status, headers, config) { growl.error(“Something went wrong”); }); console.log($scope.master); }; Now I want to add the response of this controller ie; $scope.segments = data; to […]

Extract information from response ID Angular

I am using POST to send a JSON raw body and in response I am getting an ID. But I need to show specific information passed with the JSON to that particular ID that has been created in my view. I am new in Angularjs . My controller part :- $scope.master = {}; $scope.addSegment = function(fn) { $scope.master = angular.copy(fn); $“url”, $scope.master).then(function(data) { $scope.Info = data; $scope.infoName = data.Name; $scope.infoRoll = data.Roll; $scope.infoDuration = data.Duration; […]

Not getting JSON object. AngularJS

I am new in Angular and trying to POST data , but I am getting undefined status. My JSON raw body is like this : { “Name”: “Something”, “Description”: “Something”, “Data”: [] } Name and description is from user input field and Data will be used later to push another JSON object in the array. I tried but not getting exact output. Controller:- app.controller(‘postController’, [‘$scope’, ‘$http’, ‘appService’, function ($scope, $http, AppService) { $scope.addInfos = [{ […]

How can I POST form data from Angular to Express?

I currently can successfully GET data from Express to Angular but now I am having issues sending data back. I am trying to build a very basic use case of just submitting a first/last name from my Angular site to Express to be used as a variable. Express: app.js var express = require(‘express’); var path = require(‘path’); var bodyParser = require(‘body-parser’); var http = require(‘http’); var routes = require(‘./routes/index’); var app = express(); // Parsers […]

Cannot fetch photo from database using restful api

Im trying to fetch photo of a particular userId which is stored in the database, Im able to generate response from the API as shown: but it is received in the error part of the getPhotopath() method of controller as shown: HTML: <div class=”col-md-3 ” ng-init=”modifyphoto()” > <img class=”smaller” ng-src=”fetchedimg” ng-model=”fetchedimg”><br> <p>{{userName}}</p> <div ng-model=”userType”> <p>{{userType | UserFilter}}</p> </div> <div ng-controller=”AskController”> <button class=”btn btn-default” ng-click=”gotouserdetails()”>View My Details</button> </div> </div> Controller: $scope.modifyphoto = function() { $scope.getPhotoPath(); if($scope.userPhoto==null){ […]

Next Page »