Request called by an axois instance is missing data

I have the below class for talking to a REST API endpoint:

export class DocumentRESTClient {
  /** Axios instance to be used by all derived classes */
  readonly axiosInstance: AxiosInstance

  public constructor(requiredEnvVars: APIEnvVars) {
    const requestTimeout = parseInt(requiredEnvVars.API_REQUEST_TIMEOUT?.trim() || '120000', 10)

    this.axiosInstance = axios.create({
      baseURL: requiredEnvVars.BASE_API_URL,
      timeout: requestTimeout,
    })

    this.axiosInstance.interceptors.request.use(request => {
      console.log('---------------- axois interceptor -----------------')
      console.log('Starting Request', JSON.stringify(request, null, 2))
      return request
    })

    axiosRetry(this.axiosInstance, {
      retries: 10,
      retryCondition: (error) => error?.response?.status === 429,
    })
  }

  public async postData(uri: string, data: any, headerParams: Record<string, string>, baseUrl?: string): Promise<any> {
    console.log('postData data:', data)
    return await this.axiosInstance.post(uri, data, { headers: headerParams, baseURL: baseUrl })
  }

  public async getData(
    uri: string,
    params: Record<string, unknown>,
    headerParams: Record<string, string>
  ): Promise<any> {
    return await this.axiosInstance.get(uri, { headers: headerParams, data: qs.stringify(params) })
  }
}

When I run this, the code is failing, hence I added an interceptor to see what is happening inside. It prints the below:

-------------- authorize --------------------
postData data: URLSearchParams { 'grant_type' => 'client_credentials', 'scope' => 'https://api-stg.xxx.com/.default' }
---------------- axois interceptor -----------------
Starting Request {
  "transitional": {
    "silentJSONParsing": true,
    "forcedJSONParsing": true,
    "clarifyTimeoutError": false
  },
  "transformRequest": [
    null
  ],
  "transformResponse": [
    null
  ],
  "timeout": 120000,
  "xsrfCookieName": "XSRF-TOKEN",
  "xsrfHeaderName": "X-XSRF-TOKEN",
  "maxContentLength": -1,
  "maxBodyLength": -1,
  "headers": {
    "common": {
      "Accept": "application/json, text/plain, */*"
    },
    "delete": {},
    "get": {},
    "head": {},
    "post": {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    "put": {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    "patch": {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    "Authorization": "Basic NTQwNGM2.................M",
    "Content-Type": "application/x-www-form-urlencoded"
  },
  "baseURL": "https://api-stg.xxx.com",
  "method": "post",
  "url": "/oauth2/token",
  "data": {},
  "axios-retry": {
    "retryCount": 0,
    "lastRequestTime": 1692977951412
  }
}

Seems that data is empty inside the interceptor. Why is that happening? Where are grant_type and scope? Please advise.

:contains doesn’t work for several columns

img – my column

my code:
td[id='typ']:contains('DRILL '),td[id='status']:contains('Damaged')~td[id='status']:contains('Unuse')

Why does it also show me other types in the STATUS column? not just recommended? what the query should look like

$("table#mazak407dane tbody tr "+searchs+" ").each(function(index, element){

sorry for english

i tried to use tilde or comma but the effect is still the same

JS non-encoding special character issue on Qualtrics

The issue is we are triggering a JSON Workflow event in the following way:

fetch('https://qualtrics-url.com', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-API-Token': 'xxx'
},
body: JSON.stringify({var: 'h=fi<una'})
}).then(res => res.json())
.then(res => console.log(res));

From there we send email using the var we passed above.
However, in the email we receive, h=fi only, and not the rest of the part.
If I do encodeURIComponent, then I receive the full string in encoded format in email, but I want the non-encoded version.
If I do encoded, the output will be h%3Dfi%3Cuna instead which also isn’t correct.

Any workaround with such issue?
I encountered this using JS on Qualtrics.

js never seems to leave async function

i have this code

async function wait_till_loaded() {
console.log("wait_till_loaded start")
if (start_game_bool == false)
{
    console.log("loading")
    await new Promise(r => setTimeout(r, 2000));
}
if (start_game_bool == false)
{
    console.log("loading 2 ")
    await new Promise(r => setTimeout(r, 2000));
}
if (start_game_bool == false)
{
    console.log("loading 3  ")
    await new Promise(r => setTimeout(r, 2000));
}
console.log("wait_till_loaded end ")
                  }
wait_till_loaded(); console.log("aaaaaaa") console.log(start_game_bool) if (start_game_bool == true){start_game(); console.log("started game")}

this does print

wait_till_loaded end

but this doesnt

aaaaaaa

so it just never gets out of the async function even though it gets to the end.

why?

Can you check how much room remains in a WebSocket’s send buffer?

Regarding a WebSocket’s send() method, the spec has this to say:

…if the data cannot be sent, e.g. because it would need to be buffered but the buffer is full, the user agent must flag the WebSocket as full and then close the WebSocket connection…

You can check how much data has been buffered without being sent to the network by reading a WebSocket’s bufferedAmount property, but how can you tell how many bytes remain in the buffer before it becomes full?

Got [cgi:error] AH01215: (8)Exec format error: exec of ‘/cgi-bin/echarts.js’ failed

Perl script use CGI to generate html with echarts.js. Error information like below:

[Fri Aug 25 10:07:17.488252 2023] [cgi:error] [pid xx] [client xxxx] AH01215: (8)Exec format error: exec of '/cgi-bin/echarts.js' failed, referer: http://xxxx/cgi-bin/jindl_test.pl
[Fri Aug 25 10:07:17.488731 2023] [cgi:error] [pid xx] [client xxxx] End of script output before headers: echarts.js, referer: http://xxxx/cgi-bin/jindl_test.pl

Script code like below:

#!/usr/local/bin/perl5 -w

print "Content-type: text/htmlnn";
use CGI qw(:standard);
use CGI qw(:cgi);

print "<html>n";
print "<head>n";
print "<title>test</title>n";
print "<script src="echarts.js"></script>n";
print "</head>n";

print "<body>n";
print "<div id="main" style="width: 600px;height:400px;"></div>n";
print "<script type="text/javascript">";
print "var myChart = echarts.init(document.getElementById('main'));n";
print "var option = {n";
print "title: {text: 'Demo'},n";
print "tooltip: {},n";
print "xAxis: {data: ['Shirts', 'Cardigans', 'Chiffons', 'Pants', 'Heels', 'Socks']},n";
print "yAxis: {type: 'value'},n";
print "series: [n";
print "{name: 'sales', data: [120, 200, 150, 120], type: 'line'},n";
print "{name: 'values', data: [100, 300, 250, 100], type: 'line' }n";
print "],n";
print "legend: {data: ['sales','values']}n";
print "};n";
print "myChart.setOption(option);n";
print "</script>n";

print "</body></html>n";

Is there anything not suitable in this script?

Microsoft Outlook – Auto-added Javascript in e-mail signature

I’m having a problem with the signature in Outlook. Apparently when I send an email from Outlook a commented Javascript code snippet is automatically added.

<script language="JavaScript"><!--
function msoCommentShow(anchor_id, com_id)
{
    if(msoBrowserCheck()) 
        {
        c = document.all(com_id);
        a = document.all(anchor_id);
        if (null != c && null == c.length && null != a && null == a.length)
            {
            var cw = c.offsetWidth;
            var ch = c.offsetHeight;
            var aw = a.offsetWidth;
            var ah = a.offsetHeight;
            var x  = a.offsetLeft;
            var y  = a.offsetTop;
            var el = a;
            while (el.tagName != "BODY") 
                {
                el = el.offsetParent;
                x = x + el.offsetLeft;
                y = y + el.offsetTop;
                }
            var bw = document.body.clientWidth;
            var bh = document.body.clientHeight;
            var bsl = document.body.scrollLeft;
            var bst = document.body.scrollTop;
            if (x + cw + ah / 2 > bw + bsl && x + aw - ah / 2 - cw >= bsl ) 
                { c.style.left = x + aw - ah / 2 - cw; }
            else 
                { c.style.left = x + ah / 2; }
            if (y + ch + ah / 2 > bh + bst && y + ah / 2 - ch >= bst ) 
                { c.style.top = y + ah / 2 - ch; }
            else 
                { c.style.top = y + ah / 2; }
            c.style.visibility = "visible";
}   }   }
function msoCommentHide(com_id) 
{
    if(msoBrowserCheck())
        {
        c = document.all(com_id);
        if (null != c && null == c.length)
        {
        c.style.visibility = "hidden";
        c.style.left = -1000;
        c.style.top = -1000;
        } } 
}
function msoBrowserCheck()
{
    ms = navigator.appVersion.indexOf("MSIE");
    vers = navigator.appVersion.substring(ms + 5, ms + 6);
    ie4 = (ms > 0) && (parseInt(vers) >= 4);
    return ie4;
}
if (msoBrowserCheck())
{
    document.styleSheets.dynCom.addRule(".msocomanchor","background: infobackground");
    document.styleSheets.dynCom.addRule(".msocomoff","display: none");
    document.styleSheets.dynCom.addRule(".msocomtxt","visibility: hidden");
    document.styleSheets.dynCom.addRule(".msocomtxt","position: absolute");
    document.styleSheets.dynCom.addRule(".msocomtxt","top: -1000");
    document.styleSheets.dynCom.addRule(".msocomtxt","left: -1000");
    document.styleSheets.dynCom.addRule(".msocomtxt","width: 33%");
    document.styleSheets.dynCom.addRule(".msocomtxt","background: infobackground");
    document.styleSheets.dynCom.addRule(".msocomtxt","color: infotext");
    document.styleSheets.dynCom.addRule(".msocomtxt","border-top: 1pt solid threedlightshadow");
    document.styleSheets.dynCom.addRule(".msocomtxt","border-right: 2pt solid threedshadow");
    document.styleSheets.dynCom.addRule(".msocomtxt","border-bottom: 2pt solid threedshadow");
    document.styleSheets.dynCom.addRule(".msocomtxt","border-left: 1pt solid threedlightshadow");
    document.styleSheets.dynCom.addRule(".msocomtxt","padding: 3pt 3pt 3pt 3pt");
    document.styleSheets.dynCom.addRule(".msocomtxt","z-index: 100");
}
// --></script>

I noticed that the code is added only if there is an image in the signature. Does anyone know how to prevent this code from being added automatically?

Thank you.

How can I get the same pixelation factor on images of different sizes

I’m currently working on a web game where a pixelated image will be presented to the player and will become neater over time, the goal being to guess the character hidden behind the image before the time runs out.

I’ve managed to deal with everything to do with the pixelation of the image, but I’m stuck on one problem. In my game, there’s going to be a different image every day, and not all the images available are the same size.

For example, today we’ll have image A which is a certain size (let’s say 750*750) and let’s say the pixelation factor that works best is 50.

Tomorrow, for an image B that’s 1920*1080, the same pixelation factor won’t be enough to pixelate the image in the same way as image A. It’ll be less pixelated and it’ll be too easy to identify the hidden character.

Here’s an exemple :

Image A (500*278):

BB-8 from Star Wars

The pixelation factor that works the best here is 35

Image B (2031*2708) with the same pixelation factor :

Obi-Wan Kenobi from Star Wars

That’s why the factor can’t be a constant value and must be calculated according to the size of the images. Unfortunately, I can’t think of a formula that will work regardless of image size, or even know if it’s possible.

Another solution I’ve considered is to take all the images in my game and put them in the same format, but that would take me a long time. That’s why I’m asking you in the first place.

I hope I’ve made myself clear and that you can help me. Thanks !

I’m looking for proof that `create-react-app` doesn’t run the `import/no-unused-modules` rule when auto-refreshing

I have an app created with create-react-app. I have extended the eslint functionality with an eslintrc.json file with the following rules:

"rules": {
    "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
    "react/require-default-props": "off",
    "no-param-reassign": "off",
    "jsx-a11y/alt-text": "off",
    "react/react-in-jsx-scope": "off",
    "react/display-name": "off",
    "import/no-unused-modules": [2, {"unusedExports": true}],
    "unused-imports/no-unused-imports": "error"
  },

I have noticed that rules such as unused-imports/no-unused-imports will be used on every autorefresh, and notify me if something is wrong. However, import/no-unused-modules won’t run when create-react-app autorefreshes.

When I run npx eslint . manually in the root directory, both of these rules are run fine and will pick up errors.

Theoretically, this seems sensible. My thinking is that create-react-app only checks files and modules which are imported into the build. Since import/no-unused-modules checks for files/modules which AREN’T imported by definition, this won’t be used by create-react-app.

What I’m looking for is proof (e.g. code in the create-react-app codebase) that this is the case. How does create-react-app know not to run the import/no-unused-modules rule? I have looked online and can’t find an answer to this…

Thanks!

Webview goBack() issue, not redirecting to previous page after calling goBack()

Scenario:

  1. Load Profile page(main URL) in WebView.
  2. Then click on edit number link on Profile page which loads Edit number page.
  3. Edit number page is redirected to Authentication page.
  4. On Authentication page enter OTP and submit then redirected to Edit number page.
  5. On Edit number page, Enter new number and click on submit then it shows successes message with OK button.
  6. Then click on OK button redirected to Profile page(main URL).
  7. Now if click on back button and call webView.goBack() then it redirected to Authentication page while should be redirected to Edit number page.

Note: Same behavior is happening in android emulator WebView app also
While in Chrome browser it is redirecting to the Edit number page (Expected Behavior).

Expected Behavior: After clicking on Back button it should be redirected to the Edit Number page.

Observation:

Referral Header was wrong after executing point 7 (Referral Header on Edit Number page should be authentication page URL but we are getting Edit number page URL).

Expected Behavior: After clicking on Back button it should be redirected to the Edit Number page.

MongoDb (Mongoose) aggregation issue with $lookup and $project

I am a beginner in MongoDB and am working on my personal project. I am trying to populate employees field for teamSurveyForms, but it is returning Array(0) for teamSurveyForm.employees.Can anyone tell what I am doing wrong?

            const pipeline = [
                {
                  $lookup: {
                    from: 'departments',
                    localField: 'department',
                    foreignField: '_id',
                    as: 'departmentData',
                  },
                },
                {
                    $lookup: {
                        from: 'forms',
                        localField: 'forms',
                        foreignField: '_id',
                        as: 'formsData',
                    },
                },
                {
                    $lookup:{
                      from: 'employees',
                      localField: 'teamSurveyForms.employees',
                      foreignField: '_id',
                      as: 'teamFormEmployees',
                    },
                },
                {
                  $unwind: {
                    path: '$departmentData',
                    preserveNullAndEmptyArrays: true,
                  },
                },
                {
                  $project: {
                      fName: 1,
                      lName: 1,
                      empCode: 1,
                      email: 1,
                      password:1,
                      empType: 1,
                      designation: 1,
                      DOJ:1,
                      department: '$departmentData.name',
                      selfSurveyForms: {$cond:
                        {
                            if:employeeWithForm,
                            then:{
                                $map:{
                                    input:{
                                        $filter:{
                                            input:'$formsData',
                                            as:'selfForm',
                                            cond:{$eq:['$$selfForm.FType','Self']}
                                        }
                                    },
                                    as:'selfForm',
                                    in:{
                                        _id:'$$selfForm._id',
                                        FType:'$$selfForm.FType',
                                        title:'$$selfForm.title',
                                        description:'$$selfForm.description',
                                        department: '$departmentData.name',
                                        employees:[],
                                    }
                                },
                            },
                            else:null
                        }
                      },
                      teamSurveyForms: {$cond:
                        {
                            if:employeeWithForm,
                            then:{
                                $map: {
                                    input: {
                                        $filter:{
                                            input:'$formsData',
                                            as:'teamForm',
                                            cond:{$eq:['$$teamForm.FType','Team']}
                                        }
                                    },
                                    as:'teamForm',
                                    in:{
                                        _id:'$$teamForm._id',
                                        FType:'$$teamForm.FType',
                                        title:'$$teamForm.title',
                                        description:'$$teamForm.description',
                                        department: '$departmentData.department',
                                        employees:{
                                            $map: {
                                                input: '$teamFormEmployees',
                                                as: 'employee',
                                                in: {
                                                    _id:'$$employee._id',
                                                    name: {$concat: ['$$employee.fName', ' ', '$$employee.lName']},
                                                }
                                            },
                                        },
                                    }
                                }
                            },
                            else:null
                        }
                      },
                  },
                },
                {
                    $match: findQueryData, // Apply the conditions for searching
                },
                {
                    $skip: (page - 1) * items_per_page, // Skip records based on page number
                },
                {
                    $limit: Number(items_per_page), // Limit the number of records per page
                },
            ];

            data=await FormModel.aggregate(pipeline);

I want to get data with all fields like fName,lName,empCode,email,password,empType,designation, DOJ, department and forms split into selfSurveyForms and teamSurveyForms and in both forms I need FType, title, description, department and employees. In selfSurveyForms, I am sending employees as empty array but in teamSurveyForms I need employees (which is an array of ids of employee) by populating it with employee collection.

selfSurveyForms and teamSurveyForms both are array.

Classname not working with {`…${…}…`} or not showing any style in page

I am trying the typical pokedex with the pokeapi and i’m styling it with and for eacht type i wanted to change some styles, mainly colors like background. I created a typesStyles object that has an attribute for each type, and each attribute is an object with properties like:

const typesStyles = {
    bug: {
        color: 'lime-800'
    },
// rest of types
}

I imported it as typesStyles and wanted to use it in my className’s so I did:

<div className={`bg-gradient-to-b from-${mainStyles.color} from-50% to-${secondaryStyles.color} to-50% mx-auto flex flex-col p-4 my-4 w-1/2`}>
// ...
</div>

Now my problem is that i’m getting no color at all in my localhost for some reason, i put some onClick={() => console.log(mainStyles.color)} I get said ‘lime-800’ in the console. But the weirdest or more frustrating part to me is that when I open the devtools in any browser I do get:

<div class="bg-gradient-to-b from-lime-800 from-50% to-lime-800 to-50% mx-auto flex flex-col p-4 my-4 w-1/2">
// ...
</div>

And no color at all.

And if I change my code so that it literally says '...lime-800...' it works (I don’t want that, i want to make it change por each Poke) but when I tried ...${'lime-800'}..., nothing again. Is it something with react? With tailwind maybe? although I doubt it. I know that typeStyles[bug] returns ‘lime-800’ via console.log’s
Thanks in advance.

ES6 How to import fresh array from a .js file (exported array)

Thanks for seeing my post!

Below is my array which is changed by another script after some time

export const bookFiles=[]

I have imported it in my main Express JS + Node JS route for an api, But the problem is that when I run the script it takes and remembers the values in the array and provide that to the api fetch. But I want it to re-import or re-scan the array and send it to the API fetch.

Router File:
routes/book.mjs:

import express from "express";
export const book = express.Router();
import { bookFiles } from "../Arrays/bookFiles.mjs";

book.get("/",(req,res)=>{
    const data=bookFiles
    res.send(data)
}
)

And this is my Main File
/app.mjs:


import express from 'express';
import { zip } from './routes/zip.mjs';
import { office } from './routes/office.mjs';
import { compressed } from './routes/compressed.mjs';
import { image } from './routes/images.mjs';
import { book } from './routes/book.mjs';
import { videos } from './routes/videos.mjs';



var app = express()
app.use("/zipFiles",zip)
app.use("/officeFiles",office)
app.use("/videoFiles",videos)
app.use("/compressedFiles",compressed)
app.use("/bookFiles",book)
app.use("/imageFiles",image)

app.listen("5000")

I also tried to instead readFileSync from .js file and then parse it into Array, but it didn’t worked because JSON.parse() does not support it. Thanks for the cooperation.

How do I use the Faceted Search on Oracle Apex with a interactive report instead of a classic report?

What I want to accomplish.
In Oracle APEX .I want to be able to use the faceted search with the ability to hide/show columns on the report, and then also be able to select records in the report so that I can manipulate them how I want to.

I can select the records with a classic report using JavaScript/PLSQL , or use the interactive report, but as far as I know you can’t use a Interactive report with the faceted search. I’m fine with using the classic report, but I want to be able to hide/show columns (similarly to the action button).Action button on Interactive Report

How can I either:

  • User a interactive Report Instead of a classic report
  • Use a Classic report with the same/similar Action button
  • Or accomplish something similar?

or Where can I find a relevant resource to help me?

I tried changing the classic report to a interactive report, but then the faceted search says it’s Invalid Faceted Search source section in the page designer