A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Azure/azure-functions-nodejs-worker/issues/377 below:

Binding Data for integers is inconsistent. · Issue #377 · Azure/azure-functions-nodejs-worker · GitHub

Investigative information

Please provide the following:
N/A - this issue is reproducible locally.

Repro steps

Provide the steps required to reproduce the problem:

Run the following Typescript function:

import { AzureFunction, Context, HttpRequest } from "@azure/functions"

const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise<void> {
    context.res = {
        body:context.bindingData
    }
}

With the following function.json

{
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "route": "periods/{id}",
      "methods": [
        "get"
      ]
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    }
  ],
  "scriptFile": "../dist/TestFunc/index.js"
}

Run func start

Hit the URL with 0 as the parameter:

curl <function-url>/api/periods/0

Output is:

{
  "invocationId": <hash>,
  "id": {
    "string": "0",
    "data": "string"
  },
  ....
}

Hit the URL with 1 as the parameter

curl <function-url>/api/periods/1

Output is:

{
  "invocationId": <hash>,
  "id":  1
...
}
Expected behavior

Format should be the same no matter what value is passed in.

Actual behavior

Format is integer literal for non-zero values (id: 1) and an object ({ ... }) for zero values.

Known workarounds

You can detect and respond in code, but that is ugly.

Related information

Provide any related information

Source
import { AzureFunction, Context, HttpRequest } from "@azure/functions"

const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise<void> {
    context.res = {
        body:context.bindingData
    }
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4