Categories
Mastering Development

How do I get CORS working with golang chi server?

I am trying to get cross origin request working against a golang chi server (https://github.com/go-chi/chi). The preflight request made by the browser isn’t getting the expected headers (screen shot below). Here is a script that sets up a simple go server and express server go mod init cat > main.go <<EOF package main import ( […]

Categories
CMS Drupal Mastering Development

RESTful Web Services : How to simply post a paragraph entity

I have simply activated the default paragraph ressource with core (8.8.3) module : I would like to post a paragraph but even just with the “type” field, I got 403 error in response ! I have nearly the same request that works fine for node… var newReleve = { type: [{ target_id: ‘releve_de_chantier’ }], parent_id: […]

Categories
Mastering Development

SyntaxError: Unexpected end of input in fetch API

I face a new problem that has been asked before in this link. But It is not relevant to my problem. What I have implemented is a very simple API using nodejs, express-framework and mongoose. The problem is with fetch API. I want to submit some ID and post it to the server. In the […]

Categories
Mastering Development

set model value using array in angular js

I’m using AngularJS framework. I have a text box to enter an amount and a drop down to select a type. <input type=”text” ng-model=”user.amount”/> <select ng-model=”user.rateType”> <option> rate </option> <option> unrate</option> </select> <input type=”text” ng-model=”user.assignVal”/> Here is my controller var app = angular.module(“myApp”, []); app.controller(“myCtrl”, function ($scope) { $scope.Main = [ { id: “1”, hval: […]

Categories
Mastering Development

NodeJs Streams, pipelines, and https posts

I needing a bit of a sanity check. I am running Node 11.10.1 I have a process that reads from a oracle db using the nodejs oracledb library. There is a streaming function which I do a select * and stream the results in batches of 10k objects. I then post this data to an […]

Categories
Mastering Development

Drupal 8 POST /user/login?_format=json 500 (500 Service unavailable (with message))

I am trying to get a simple user login to work using fetch POST in a ReactJS app against Drupal 8.8 Rest endpoint so I can POST with CSRF or other methods. If I issue the following with a CURL request: curl –header “Content-type: application/json” –request POST –data ‘{“name”:”myname”, “pass”:”mypassword123″}’ http://example.com/user/login?_format=json … I get … […]

Categories
Mastering Development

Parameter in query graphql breaking JSON with NodeJS

my script connects to a graphql API by fetch and inserts the JSON return in the postgresql database, however when I insert the primaryLabels parameter into the query, it returns that my JSON is broken by a token>. If I remove this parameter, everything goes perfectly, any solution? I tried to turn the query into […]

Categories
Mastering Development

Guzzel Exception – 500 Internal Server Error

I’m trying to get a response for the API endpoint but it’s resulting in an error saying that Server error: POST http://base_url/api/servicebookingrequest resulted in a 500 Internal Server Error response:\n{\”Message\”:\”An error has occurred.\”}\n”, I just added the code that so far writtern try { \Validator::make($req->all(), [ ‘chassis_no’ => ‘string’, ‘registration_no’ => ‘string’, ‘dealer_code’ => ‘string’, […]

Categories
Mastering Development

middleware setting cors headers works with app.use() but not for specific route

middleware: const enableCors = (req, res, next) => { res.set({ ‘Access-Control-Allow-Origin’: ‘http://127.0.0.1:5500’, ‘Access-Control-Allow-Headers’: ‘content-type’ }); next(); }; //this works from postman as well as from browser The above middleware works fine when added like this app.use(enableCors); but I want it to work with a specific route and I use it like follows: app.post(‘/resource’, enableCors, (req, […]

Categories
Mastering Development

How to create a login system using mongo,express,node and vue?

I am trying to create a login system using mongodb,express,node and vue. I have created the register page and the user details are stored in mongodb, but I am unsure on how to check if the details stored in the mongodb match with the details the user enters to login. I’m getting this error message […]