I'm trying to post form-urlencoded in Axios
This is my code
const qs = require("qs");
const axios = require("axios");
const tmp = { id: "96e8ef9f-7f87-4fb5-a1ab-fcc247647cce", filter_type: "2" };
axios
.post("https://www.lalal.ai/api/preview/", qs.stringify(tmp))
.then((result) => {
console.log(result);
});
This what I got
(node:2440) UnhandledPromiseRejectionWarning: Error: Request failed with status code 403
at createError (D:\reactjs\crud-mern\server\node_modules\axios\lib\core\createError.js:16:15)
at settle (D:\reactjs\crud-mern\server\node_modules\axios\lib\core\settle.js:17:12)
at IncomingMessage.handleStreamEnd (D:\reactjs\crud-mern\server\node_modules\axios\lib\adapters\http.js:244:11)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (_stream_readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2440) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:2440) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Can anyone explain to me what is the error and how to fix it? thanks :D
In the error response it states Request failed with status code 403. 403 usually means "Forbidden" and that you do not have access to perform that request. I would check to make sure you have any access keys, tokens, or authorization required to make that request.
403 Forbidden: The server understood the request, but is refusing to fulfill it. (Source)
Related
I get this error:
Error: Can't find training file, please try to specify it with the --source option
I thought it was a file path issue, so I added source and still got an error:
(node:36619) UnhandledPromiseRejectionWarning: Can't parse json file "/Users/Cos-Ibe/Futo_Chatbot/data/data.json"
SyntaxError: Unexpected token in JSON at position 0
(Use `node --trace-warnings ...` to show where the warning was created)
(node:36619) UnhandledPromiseRejectionWarning: Unhandled promise
rejection. This error originated either by throwing inside of an async
function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:36619) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'findIndex' of undefined
at User.addToCart (D:\Pradip_All\Nodejs- tutorials video (MONGODB)\models\user.js:20:46)
at D:\Pradip_All\Nodejs- tutorials video (MONGODB)\controllers\shop.js:70:23
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:11212) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict`
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:11212) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
ERROR DESCRIPTION
You should add the ? optional chaining operator that check if the value exists in the object.
const cartProductIndex = this.cart?.items?.findIndex((cp) => {
return cp.productId.toString() === product._id.toString()
})
Short version:
I am looking for a way to way to run my NestJS application with the '--trace-warnings' flags that nodeJS offers. Is there some way to do this or does NestJS offer something similar?
Long version:
Hi! NestJS noob here. I am trying to run a dev version of the NestJS application I am working on. However, on starting the application I get the error below.
Clearly, it is missing a catcherror somewhere! However, the dev version has a LOT of updates and this error can be anywhere so I am hoping for a more efficient way of finding this bug than just checking every single new function! In the errormessage there are a few tips on flags to run while starting the application (node --trace-warnings ...). However, these are for node and not NestJS.
So therefore my question; is there some way to run NestJS with the --trace-warnings flag or some other efficient way to find where I am missing the catcherror?
Thanks in advance!
Error:
(node:72899) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:72899) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:72899) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:72899) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16)
(node:72899) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
Well, 6379 is the Redis default port, it seems like Nest cannot connect to it :)
By the way, give a look at this paragraph:
https://docs.nestjs.com/exception-filters#catch-everything
In order to catch every unhandled exception (regardless of the
exception type), leave the #Catch() decorator's parameter list empty,
e.g., #Catch().
import {
ExceptionFilter,
Catch,
ArgumentsHost,
HttpException,
HttpStatus,
} from '#nestjs/common';
#Catch()
export class AllExceptionsFilter implements ExceptionFilter {
catch(exception: unknown, host: ArgumentsHost) {
const ctx = host.switchToHttp();
const response = ctx.getResponse();
const request = ctx.getRequest();
const status =
exception instanceof HttpException
? exception.getStatus()
: HttpStatus.INTERNAL_SERVER_ERROR;
response.status(status).json({
statusCode: status,
timestamp: new Date().toISOString(),
path: request.url,
});
}
}
To answer your specific question:
I am looking for a way to way to run my NestJS application with the '--trace-warnings' flags that nodeJS offers. Is there some way to do this or does NestJS offer something similar?
I've been trying to do the same thing, and there seems to be next-to-no documentation online on how to do this. Through some trial and error, I've found that this seems to work:
node --trace-warnings -r source-map-support/register --inspect dist/main
Note that this won't rebuild your application (neither when you first start it up, or by watching for changes), so you'll need to do that manually. The debugger is enabled via --inspect switch, remove that if you don't need to debug.
try to use a npm response / request logger like winston or moesif you will get a lot of help trust me.
here are the links for these library for nestjs
https://github.com/scalio/nest-couchdb
when i am running my app.js file i am getting UnhandledPromiseRejectionWarning: MongoParseError: Invalid connection string.
the whole error in my terminal is:
$ node app.js
(node:18676) UnhandledPromiseRejectionWarning: MongoParseError: Invalid connection string
at parseConnectionString (C:\Users\Dell\Documents\Extra\fruit\node_modules\mongodb\lib\core\uri_parser.js:565:21)
at connect (C:\Users\Dell\Documents\Extra\fruit\node_modules\mongodb\lib\operations\connect.js:282:3)
at C:\Users\Dell\Documents\Extra\fruit\node_modules\mongodb\lib\mongo_client.js:224:5
at maybePromise (C:\Users\Dell\Documents\Extra\fruit\node_modules\mongodb\lib\utils.js:665:3)
at MongoClient.connect (C:\Users\Dell\Documents\Extra\fruit\node_modules\mongodb\lib\mongo_client.js:220:10)
at C:\Users\Dell\Documents\Extra\fruit\node_modules\mongoose\lib\connection.js:820:12
at new Promise ()
at NativeConnection.Connection.openUri (C:\Users\Dell\Documents\Extra\fruit\node_modules\mongoose\lib\connection.js:817:19)
at C:\Users\Dell\Documents\Extra\fruit\node_modules\mongoose\lib\index.js:345:10
at C:\Users\Dell\Documents\Extra\fruit\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:5
at new Promise ()
at promiseOrCallback (C:\Users\Dell\Documents\Extra\fruit\node_modules\mongoose\lib\helpers\promiseOrCallback.js:30:10)
at Mongoose._promiseOrCallback (C:\Users\Dell\Documents\Extra\fruit\node_modules\mongoose\lib\index.js:1135:10)
at Mongoose.connect (C:\Users\Dell\Documents\Extra\fruit\node_modules\mongoose\lib\index.js:344:20)
at Object. (C:\Users\Dell\Documents\Extra\fruit\app.js:3:10)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
(Use node --trace-warnings ... to show where the warning was created)
(node:18676) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not
handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:18676) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:18676) UnhandledPromiseRejectionWarning: MongooseError: Operation fruits.insertOne() buffering timed out after 10000ms
at Timeout. (C:\Users\Dell\Documents\Extra\fruit\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:184:20)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
(node:18676) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not
handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)
The Code is given below:
const mongoose=require('mongoose');
mongoose.connect('monogodb://localhost:27017/fruitsDB',{ useNewUrlParser:true,family:4});
const fruitSchema=new mongoose.Schema({
name:String,
rating:Number,
review:String
});
const Fruit=mongoose.model("Fruit",fruitSchema);
const fruit=new Fruit({
name:"Apple",
rating:7,
review:"Pretty Good!"
});
fruit.save();
You have a typo at the beginning of your connection string, monogodb instead of mongodb.
Solution make sure your MongoDB URL connection string is correct or misspelled
"mongodb://myDBReader:D1fficultP%40ssw0rd#mongodb0.example.com:27017/?authSource=admin" or
"mongodb://mongodb0.example.com:27017"
I got the following error while trying to convert a jpeg image to webp by using Pixellena Lux API.
(node:13962) UnhandledPromiseRejectionWarning: #<RequestIssueException>
(Use `node --trace-warnings ...` to show where the warning was created)
(node:13962) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:13962) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Documentation of API.
https://pixellena.com/docs/sdk/
I just updated the following part as
let adjustments = {
"shifter": {
"steps": [
{
"scale-to": {
"width": 10
}
}
]
},
"encoder": {
"quality-measure": "fsim-c",
"qual-threshold": 2.0
}
}
This error appears because the value of "qual-threshold" must be between 0.25 and 1.0.
There is some doc about qual-threshhold at https://demo.pixellena.com/adjustments, and https://pixellena.com/docs/lux-api/ that you can check.