Error occurred prerendering page “/Contact”. Read more: https://nextjs.org/docs/messages/prerender-error TypeError: t(…).map is not a function

npm run dev success

npm run build error

Error occurred prerendering page “/Contact”. Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: t(…).map is not a function
at Contact (E:reactbig-power.nextserverchunks736.js:1:1394)
at Wc (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:68:44)
at Zc (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:70:253)
at Z (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:76:89)
at $c (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:78:98)
at Zc (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:71:145)
at Z (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:76:89)
at Zc (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:70:481)
at Z (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:76:89)
at Zc (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:74:209)
TypeError: v(…).map is not a function
at Sustanabuty_Sustanabuty (E:reactbig-power.nextserverchunks302.js:1:5909)
at Wc (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:68:44)
at Zc (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:70:253)
at Z (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:76:89)
at $c (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:78:98)
at Zc (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:71:145)
at Z (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:76:89)
at Zc (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:70:481)
at Z (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:76:89)
at Zc (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:74:209)

Error occurred prerendering page “/Sustanabuty”. Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: v(…).map is not a function
at Sustanabuty_Sustanabuty (E:reactbig-power.nextserverchunks302.js:1:5909)
at Wc (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:68:44)
at Zc (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:70:253)
at Z (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:76:89)
at $c (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:78:98)
at Zc (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:71:145)
at Z (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:76:89)
at Zc (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:70:481)
at Z (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:76:89)
at Zc (E:reactbig-powernode_modulesreact-domcjsreact-dom-server.browser.production.min.js:74:209)
Generating static pages (8/44) [= ]
TypeError: v(…).map is not a function

enter image description here
Error occurred prerendering page “/Sustanabuty”. Read more: https://nextjs.org/docs/messages/prerender-error

React Native Android app crash. app.MainActivity (server)’ ~ Channel is unrecoverably broken and will be disposed?

System:
OS: macOS 14.1.1
CPU: (8) arm64 Apple M1
Memory: 124.52 MB / 16.00 GB
Shell: 5.9 – /bin/zsh
Binaries:
Node: 20.8.1 – /opt/homebrew/bin/node
Yarn: 1.22.19 – /opt/homebrew/bin/yarn
npm: 10.1.0 – /opt/homebrew/bin/npm
Watchman: 2023.10.09.00 – /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 – /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 23.0, iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0
Android SDK:
API Levels: 23, 27, 28, 29, 30, 31, 32, 33
Build Tools: 27.0.3, 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0, 33.0.0, 33.0.2
System Images: android-28 | Google APIs ARM 64 v8a, android-28 | Google ARM64-V8a Play ARM 64 v8a, android-29 | Google APIs ARM 64 v8a, android-30 | Google APIs ARM 64 v8a, android-30 | Google Play ARM 64 v8a, android-31 | Google APIs ARM 64 v8a, android-32 | Google APIs ARM 64 v8a, android-33 | Google APIs ARM 64 v8a, android-34 | Google APIs ARM 64 v8a
Android NDK: 22.1.7171670
IDEs:
Android Studio: 2022.1 AI-221.6008.13.2211.9619390
Xcode: 15.0.1/15A507 – /usr/bin/xcodebuild
Languages:
Java: 18.0.1.1 – /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.1 => 17.0.1
react-native: 0.64.2 => 0.64.2
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

I have already check memory leak issue some logic issue but no any issue for this.

How do I get the anchorNode from a Selection object now?

For at least a year, I’ve been running JavaScript as part of a Mac Automator routine to look up right-clicked links. The URL is then passed to the next automator step to process.

The JavaScript to retrieve the URI was:

function run(input, parameters) {
    var app = Application("Safari");
    app.includeStandardAdditions = true;

    var url = app.doJavaScript('window.getSelection().anchorNode.parentNode.href',{
       in: app.windows[0].currentTab
    });

In the last few weeks, this stopped working, in both Safari and Orion. It looks like I’m still getting back a selection object from getSection(), but that the anchorNode (and the focusNode) are always null.
Did something change in WebKit recently? Is there some other way I should be doing this?

Words are colored after pressing the space key on the keyboard. I would like to color them immediately after the last letter

I have a problem with a Javascript script to color text. There are strings set for coloring, but the word is only colored when I press the “space” key on the keyboard. If i write the word, it doesn’t color. If I write the word and press the space key it becomes colored.

I would like to color the word immediately as i write it, without waiting to press the space button. For example, i set that HELLO should be colored. I would like it to color immediately as soon as I finish pressing the final O, and not when i type HELLO (with a final space).

The problem occurs when you try to manually write something in the code panel, for example if you write Hello. The problem lies in the changeColor() function, there is a Keyup Event and a Space Key Pressed.

I tried to remove the part of the code that concerns the EventListener(“keyup”… and the keycode, but everything breaks and doesn’t work. I am new to Javascript, I can’t solve it.

index.html

  <div id="editor" contenteditable="true" oninput="showPreview();" onchange="changeColor();">&lt;h1>This is a Heading&lt;/h1>
    &lt;p>This is a paragraph.&lt;/p>
  </div>
    
    <h3>PREVIEW</h3>
    <div class="preview-area">
      <iframe id="preview-window"></iframe>
    </div>

style.css

#editor {
  width: 400px;
  height: 100px;
  padding: 10px;
  background-color: #444;
  color: white;
  font-size: 14px;
  font-family: monospace;
  white-space: pre;
}
.statement {
  color: orange;
}

javascript.js

function applyColoring(element) {
    var keywords = ["DIV", "DIV", "H1", "H1", "P", "P", "HELLO", "<", ">", "/"];
  
    var newHTML = "";
    // Loop through words
    str = element.innerText;
    (chunks = str
      .split(new RegExp(keywords.map((w) => `(${w})`).join("|"), "i"))
      .filter(Boolean)),
      (markup = chunks.reduce((acc, chunk) => {
        acc += keywords.includes(chunk.toUpperCase())
          ? `<span class="statement">${chunk}</span>`
          : `<span class='other'>${chunk}</span>`;
        return acc;
      }, ""));
    element.innerHTML = markup;
  }
  


  // CHANGE COLOR 
  function changeColor() {
    // Keyup event
    document.querySelector("#editor").addEventListener("keyup", (e) => {
      // Space key pressed
      if (e.keyCode == 32) {
        applyColoring(e.target);
  
        // Set cursor postion to end of text
        //    document.querySelector('#editor').focus()
        var child = e.target.children;
        var range = document.createRange();
        var sel = window.getSelection();
        range.setStart(child[child.length - 1], 1);
        range.collapse(true);
        sel.removeAllRanges();
        sel.addRange(range);
        this.focus();
      }
    });
  }
  
changeColor()
applyColoring(document.getElementById('editor'));


//PREVIEW
function showPreview() {
    var editor = document.getElementById("editor").innerText;
  
    // var cssCode =
    //  "<style>" + document.getElementById("cssCode").value + "</style>";
    // var jsCode =
    //  "<scri" + "pt>" + document.getElementById("jsCode").value + "</scri" + "pt>";
    
    var frame = document.getElementById("preview-window").contentWindow.document;
    document.getElementById("preview-window").srcdoc = editor;
    frame.open();
    //frame.write(htmlCode + cssCode + jsCode);
    frame.write(editor);
    frame.close();
  }
  
  showPreview()

trying to create an isogram using javascript (but there’s something i don’t understand)

so i’m fairly new to coding and i’m trying to make an isogram using javascript (without using any built-in methods because i’m still learning the basics) but i’m having difficulty grasping the logic behind this programming language. this is the code i initially used…

const isogram = word => {

  for(let i= 0; i< word.length; i++){ 
    for(let j = i+1; j< word.length; j++){
      if(word[i] === word[j]){
        console.log(`the letter '${word[j]}' is repeated`)
      } 
    }
  }
}

input: console.log(isogram("happy"));

//output: the letter 'p' is repeated

as you can see it worked fine UNITL i added an ‘else-statement’ and it went crazy:

const isogram = word => {

  for(let i= 0; i< word.length; i++){ 
    for(let j = i+1; j< word.length; j++){
      if(word[i] === word[j]){
        console.log(`the letter '${word[j]}' is repeated`)
      } else {
        console.log(`'${word}' is an isogram`)
      }
    }
  }
}

input: console.log(isogram("happy"));
//output: 'happy' is an isogram
'happy' is an isogram
'happy' is an isogram
'happy' is an isogram
'happy' is an isogram
'happy' is an isogram
'happy' is an isogram
the letter 'p' is repeated
'happy' is an isogram
'happy' is an isogram

input: console.log(isogram("cake"))
//output: 'cake' is an isogram
'cake' is an isogram
'cake' is an isogram
'cake' is an isogram
'cake' is an isogram
'cake' is an isogram

there’s two issues with this outcome:

  1. when i input a word that’s NOT and isogram in this case ‘happy’, it prints out the else-statement which states that the word is indeed an isogram (even though happy isn’t an isogram). However, it also points out the letter in the word that’s repeated which in this case is the letter ‘p’ in ‘happy’.

  2. when i input a word that’s an isogram like ‘cake’, it says it’s an isogram (which is good) but it says it multiple times instead of once…

i think it’s something to do with the nested ‘for loops’, so maybe the ‘if’ and the ‘else’ console statements are printing out for each character within the word instead of the word as a whole? for example for ‘happy’ i’m presuming this is what it’s doing:

h ‘happy’ is an isogram //first loop
h ‘happy’ is an isogram //second loop
a ‘happy’ is an isogram //first loop
a ‘happy’ is an isogram //second loop
p ‘happy’ is an isogram //first loop
p ‘happy’ is an isogram //second loop
p ‘happy’ is an isogram //first loop
p the letter ‘p’ is repeated //second loop
y ‘happy’ is an isogram //first loop
y ‘happy’ is an isogram //second loop

i also tried fixing it by replacing the else-statement with the return keyword but i came across another problem; this time when i input an isogram word it prints both statements whereas with a none-isogram word in works fine.

const isogram = word => {

  for(let i= 0; i< word.length; i++){ 
    for(let j = i+1; j< word.length; j++){
      if(word[i] === word[j]){
        console.log(`the letter '${word[j]}' is repeated`)
      } 
    } 
  }
  return `'${word}' is an isogram`
}

input: console.log(isogram("happy"));
//output: the letter 'p' is repeated
'happy' is an isogram

input: console.log(isogram("cake"))
//output: 'cake' is an isogram

overall i’m confused: why did this only start happening once i added the ‘else’ statement? what’s the logic behind this? how can i fix it so that the console statements are only printed once? also how could i efficiently use the return keyword here?

i simply want the console to print “the letter ‘ ‘ is repeated” when it’s NOT and isogram
and to print “‘word’ is an isogram” if the the word is an isogram.

Why does changing the x and y variables of ctx.fillRect(x, y, 100, 100); not change the position of the square?

When I click the arrow keys (37, 38, 39, and 40) the variables of x and y change yet the position of the square given by ctx.fillRect(x, y, 100, 100); does not change. How come? And is there any solution?

<!DOCTYPE html>
<html>
<body>

<canvas id="canvasSpace" width="1460" height="710" style="border:2px solid #000000;"></canvas>

    <script>
        const canvas = document.getElementById("canvasSpace");
        const ctx = canvas.getContext("2d");
        let x = 735, y = 360
        ctx.fillRect(x, y, 100, 100);

        function moveLeft() {x -= 10;}
        function moveUp() {y += 10;}
        function moveRight() {x += 10;}
        function moveDown() {y -= 10;}

        function log() {
        alert("x = " + x)
        alert("y = " + y)
        }

        document.addEventListener('keydown', function(event) {
            if (event.keyCode == 37) {moveLeft();}
            if (event.keyCode == 38) {moveUp();}
            if (event.keyCode == 39) {moveRight();}
            if (event.keyCode == 40) {moveDown();}
            if (event.keyCode == 13) {log();}
        });
    </script>

</body>
</html>

I added the log function to trigger when the enter key (13) was pressed to make sure the variables change. Yet this doesn’t appear to be the problem as the variables do change.

Highlighting specified text with embedded link with Chrome Extension [duplicate]

Here is my content.js which has a function that highlights specified text.

function isElementVisible(element) {
    const style = window.getComputedStyle(element);
    return style.display !== 'none' && style.visibility !== 'hidden';
  }

  function highlightLetter(node, targetLetter, highlightColor, tooltipContent) {
    if (node.nodeType === Node.TEXT_NODE && isElementVisible(node.parentElement)) {
      const textContent = node.textContent;
  
      // Match targetLetter only if it is the first or last character of a word
      const pattern = new RegExp(`\b${targetLetter}|${targetLetter}\b`, 'gi');
  
      const newContent = textContent.replace(pattern, match => `<span class="tooltip"><mark style="background-color: ${highlightColor}">${match}</mark><span class="tooltiptext">${tooltipContent}</span></span>`);
  
      if (newContent !== textContent) {
        const newNode = document.createElement('span');
        newNode.innerHTML = newContent;
        node.replaceWith(newNode);
      }
    } else if (node.nodeType === Node.ELEMENT_NODE && isElementVisible(node)) {
      node.childNodes.forEach(childNode => highlightLetter(childNode, targetLetter, highlightColor, tooltipContent));
    }
  }

Here are the other files for a minimal reproducible example.
Here is my manifest.json

{
    "manifest_version": 3,
    "name": "Text Highlighter",
    "version": "1.0",
    "description": "Highlight text in a web page.",
    "permissions": [
      "activeTab"
    ],
    "background": {
        "service_worker": "background.js"
      },
    "content_scripts": [
      {
        "matches": ["<all_urls>"],
        "css": ["styles.css"],
        "js": ["content.js"]
      }
    ]
  }

Here is my styles.css

.tooltip {
    position: relative;
    display: inline-block;
    cursor: pointer;
  }

  /* Hide the tooltip by default */
  .tooltip .tooltiptext {
    visibility: hidden;
    width: 120px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -60px;
    opacity: 0;
    transition: opacity 0.3s;
  }

  /* Display the tooltip when hovering over the parent span */
  .tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
  }

I tried to highlight this part of the html, as you can see it has a link embedded within the text. (link to actual page: https://www.cnn.com/2023/12/31/politics/donald-trump-2024-voter-turnout/index.html):
The former president leads the current president in more than his fair share of polls of registered voters, including in a number of <a href="https://www.nytimes.com/2023/11/05/us/politics/biden-trump-2024-poll.html" target="_blank">key swing states</a>

I called the function in content.js
highlightLetter(document.body, 'The former president leads the current president in more than his fair share of polls of registered voters, including in a number of key swing states.', 'red', '[insert tooltip content]');

but it did not highlight anything, I’m thinking its because it extended across multiple nodes because of the embedded link. How can I make this work?

How to create an upsell on the thank you page?

my question is, how do I create an upsell page and link it to a button? For example, a visitor visits my site and makes a purchase, so on the thank you page, I would like another offer to be presented to them. Or after a visitor has subscribed to my newsletter, I want an offer to be presented to them immediately.How do I do the linking thing on the html?

Thank you.

I searched almost everywhere but couldn’t get what I want to know

JS: the text does not automatically color when I open the html file. Problem starting the function

I have problems with the javascript script to color the text. It works correctly, but the text only colors if you click on the panel and press the “space” button on the PC keyboard. If you press any other key (even Enter), the text does not color.

enter image description here

I would like the script to activate automatically as soon as I open the html file, so that the text is automatically colored as soon as I open the file.

In the html i tried using the function as both onchange and oninput. While in the js file i call the changeColor() function after creating it, with the aim of executing it automatically as soon as you open the file, but it doesn’t work. Sorry for the problem, but i’m new. How can i solve it?

index.html

  <div id="editor" contenteditable="true" oninput="showPreview();" onchange="changeColor();">&lt;h1>This is a Heading&lt;/h1>
    &lt;p>This is a paragraph.&lt;/p>
  </div>
    
    <h3>PREVIEW</h3>
    <div class="preview-area">
      <iframe id="preview-window"></iframe>
    </div>

style.css

#editor {
  width: 400px;
  height: 100px;
  padding: 10px;
  background-color: #444;
  color: white;
  font-size: 14px;
  font-family: monospace;
  white-space: pre;
}
.statement {
  color: orange;
}

javascript.js

// CHANGE COLOR TEXT
function changeColor() {

var keywords = ["DIV", "DIV", "H1", "H1", "P", "P", "HELLO", "<", ">", "/"];
// Keyup event
document.querySelector("#editor").addEventListener("keyup", (e) => {
    // Space key pressed
    if (e.keyCode == 32) {
    var newHTML = "";
    // Loop through words
    str = e.target.innerText;
    (chunks = str
        .split(new RegExp(keywords.map((w) => `(${w})`).join("|"), "i"))
        .filter(Boolean)),
        (markup = chunks.reduce((acc, chunk) => {
        acc += keywords.includes(chunk.toUpperCase())
            ? `<span class="statement">${chunk}</span>`
            : `<span class='other'>${chunk}</span>`;
        return acc;
        }, ""));
    e.target.innerHTML = markup;

    // Set cursor postion to end of text
    //    document.querySelector('#editor').focus()
    var child = e.target.children;
    var range = document.createRange();
    var sel = window.getSelection();
    range.setStart(child[child.length - 1], 1);
    range.collapse(true);
    sel.removeAllRanges();
    sel.addRange(range);
    this.focus();
    }
})
}
    
changeColor()


//PREVIEW
function showPreview() {
    var editor = document.getElementById("editor").innerText;
  
    // var cssCode =
    //  "<style>" + document.getElementById("cssCode").value + "</style>";
    // var jsCode =
    //  "<scri" + "pt>" + document.getElementById("jsCode").value + "</scri" + "pt>";
    
    var frame = document.getElementById("preview-window").contentWindow.document;
    document.getElementById("preview-window").srcdoc = editor;
    frame.open();
    //frame.write(htmlCode + cssCode + jsCode);
    frame.write(editor);
    frame.close();
  }
  
  showPreview()

NestJS Passport Local ends up never responding

I’m trying to implement authentication system described in https://docs.nestjs.com/recipes/passport using Passport Strategies and Guards. When I use AuthGuard('local') to validate and issue jwt tokens to users I end up waiting for response forever. Here are my code snippets

// auth.module.ts
@Module({
  controllers: [AuthController],
  providers: [AuthService, LocalStrategy, JwtStrategy, RefreshJwtStrategy],
  imports: [
    UsersModule,
    ConfigModule,
    PassportModule,
    JwtModule.registerAsync({
      inject: [ConfigService],
      imports: [ConfigModule],
      useFactory: (configService: ConfigService) => ({
        secret: configService.get<string>('JWT_SECRET_KEY'),
        signOptions: {
          expiresIn: configService.get<string>('JWT_ACCESS_TOKEN_TTL'),
        },
      }),
    }),
  ],
})
export class AuthModule {}
// auth.service.ts
export class AuthService {
  constructor(
    private readonly userRepository: UsersRepository,
    private readonly jwtService: JwtService,
    private readonly configService: ConfigService,
  ) {}

  /**
   * Return user with given username and matching password.
   * @param email User's email.
   * @param password User's password.
   */
  public async validateUser(
    email: string,
    password: string,
  ): Promise<User | null> {
    const user = await this.userRepository.getUserByEmail(email);

    if (user && (await compare(password, user.password))) return user;

    return null;
  }

  public async createTokenPair(user: any): Promise<TokenPairEntity> {
    // This is omitted for the sake of brevity.
  }
}
// users.repository.ts
@Injectable()
export class UsersRepository {
  public constructor(
    @InjectModel(User.name) private readonly userModel: Model<User>,
  ) {}

  public async getUserByEmail(email: string): Promise<User | null> {
    return this.userModel.findOne({ email }).select(['-__v']).exec();
  }

  // Other methods are omitted for the sake of brevity.
}
// auth.strategy.ts
@Injectable()
export class LocalStrategy extends PassportStrategy(Passport, 'local') {
  public constructor(private readonly authService: AuthService) {
    super({ usernameField: 'email', passwordField: 'password' });
  }

  public async validate(email: string, password: string): Promise<User> {
    const user = await this.authService.validateUser(email, password);

    if (!user) throw new UnauthorizedException();

    return user;
  }
}
// auth.guards.ts
export class LocalAuthGuard extends AuthGuard('local') {}
// auth.controller.ts
@Controller('auth')
export class AuthController {
  public constructor(private readonly authService: AuthService) {}

  @Post('login')
  @UseGuards(LocalAuthGuard)
  public async login(@Request() req: Req): Promise<TokenPairEntity> {
    return this.authService.createTokenPair(req.user);
  }
}

After some debugging I found that my request gets stuck in LocalGuard.canActivate().

// auth.guards.ts
export class LocalAuthGuard extends AuthGuard('local') {
  public canActivate(
    context: ExecutionContext,
  ): boolean | Promise<boolean> | Observable<boolean> {
    const result = super.canActivate(context);
    console.log(result);
    return result;
  }
}

Here console.log(result) prints Promise { <pending> }. LocalStrategy’s validate method is not reached after this.

Python Flask Socket as Listener for Database Changes

I want to make a Websocket that sends a message to the connected clients when something changes in a specific table in the database. I already have the functions for changing items in the db and want to call a function that notifies the clients.

def addXtoDB(...):
    # code to add...
    notifyClients();

def editXtoDB(...):
    # code to edit...
    notifyClients();


def notifyClients();
    # ??

And how can I access that in Javascript/Typescript?

NextJS: directly forward request to backend and response to client in /api

My project stack consists of a Next.js server to handle front-end and a separate backend server to store user data etc,.

When a client wants to send a request to the back end, they send an API request to the Next.js server, which then gets data from the separate backend server.

The problem is, I can’t figure out how to forward these requests to the server and the response from the server to the client without data being lost, or the code being very messy.

This is what I’m using right now:

export default function handler(req: NextApiRequest, res: NextApiResponse){
    fetch(url, {
        method: "post",
        body: req.body
     }).then(response => res.status(200).json(response.body))
}

Obviously, with this solution, the headers are lost. I could manually add a headers field, but that was just an example. There are lots of other fields to add, and I’m looking for a way to include all of them.

Important Note: the reason I have to intercept the request is to insert JWT token.

Google map car icon rotation

How can I rotate car icon (svg file) right, left, up, down by the latitude and longitude values from current driver’s driving route.

I’ve a method that bears a angle but it is requiring From Lat/Long to To Lat/Lang, driver is returning only current latitude/longitude values as it is driving on road without destination.

My requirement is I should be able to see my active drivers on google map driving and taking turns on roads like right, left without any destination or pickup location.

Need a javascript function to rotate car icon by current driver’s latitude/longitude.

Thanks,
Abdul

Need a javascript function to rotate car icon by current driver’s latitude/longitude.

Foreach loop solution in Php or JavaScript

I want to create a foreach loop where I compare a value A with a different value (Value (n)) with each loop , and if the value A is greater than the value (n) the loop should continue till the items in loop are finished.

But the catch is that I want the value of A to be subtracted from by the value (n) it was compared to, with each interaction. So that in the next iteration
Value A is less than it was in the previous loop
i.e new value of A = value A – Value (n).

Don’t know how to return the new value of A to the ongoing foreach loop

I can’t seem to figure it out yet. Lack of knowledge I guess.