Welcome! Log In Create A New Profile

Advanced

Re: NJS Questions and/or Bugs

Sergey A. Osokin
August 11, 2021 10:42PM
On Wed, Aug 11, 2021 at 09:31:41PM -0500, Lance Dockins wrote:
> Hi Sergey,
>
...
>
> dbadmin.js
> function access(r){
>     r.return(200, JSON.stringify(r.args));
>
>     r.internalRedirect('@php');

Two points:
- missing return directive here;
- r.internalRedirect will never happend because of r.return above.

> }
>
> export default {access}

Here's my code that works as expected:

function argskeyvalue(r) {
var jObj = JSON.stringify(r.args) + '\n';

try {
var parseJSON = JSON.parse(jObj);
} catch (err) {
r.return(400, 'Cannot parse jObj');
return;
}

r.return(200, jObj);

return;
}

export default { argskeyvalue };

As you can see it creates a JSON object jObj, then test it's
parseable and if so return 200.

Hope that helps.

--
Sergey
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

NJS Questions and/or Bugs

Lance Dockins August 11, 2021 08:44PM

Re: NJS Questions and/or Bugs

Sergey A. Osokin August 11, 2021 09:52PM

Re: NJS Questions and/or Bugs

Lance Dockins August 11, 2021 10:06PM

Re: NJS Questions and/or Bugs

Sergey A. Osokin August 11, 2021 10:22PM

Re: NJS Questions and/or Bugs

Lance Dockins August 11, 2021 10:32PM

Re: NJS Questions and/or Bugs

Lance Dockins August 11, 2021 10:40PM

Re: NJS Questions and/or Bugs

Sergey A. Osokin August 11, 2021 10:44PM

Re: NJS Questions and/or Bugs

Lance Dockins August 11, 2021 10:50PM

Re: NJS Questions and/or Bugs

Sergey A. Osokin August 11, 2021 10:58PM

Re: NJS Questions and/or Bugs

Lance Dockins August 11, 2021 11:02PM

Re: NJS Questions and/or Bugs

Lance Dockins August 11, 2021 11:46PM

Re: NJS Questions and/or Bugs

Lance Dockins August 11, 2021 11:52PM

Re: NJS Questions and/or Bugs

Sergey A. Osokin August 11, 2021 10:42PM

Re: NJS Questions and/or Bugs

Dmitry Volyntsev August 12, 2021 02:16AM

Re: NJS Questions and/or Bugs

Lance Dockins August 12, 2021 08:40AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 302
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready