How to properly set the redirectUri when using Expo AuthSession with Azure and Azure Active Directory?

there is a problem with the redirect when getting the AccessToken.

This is the error:

Invariant violation: AccessTokenRequest requires a valid redirectUri (must also match the one used in the authentication request). Example: myapp://redirect

const [username, setUsername] = useState('');
    const [token, setToken] = useState('');
    const [email, setEmail] = useState('');
    const [discovery, setDiscovery] = useState([]);
    const [authRequest, setAuthRequest] = useState([]);
    const [authorizeResult, setAuthorizeResult] = useState(null);

    const scopes = ["openid", "profile", "email", "offline_access"];
    const domain = `https://login.microsoftonline.com/${tenetID}/v2.0`;
    const redirectUrl = AuthSession.makeRedirectUri({
        scheme: "exp",
        useProxy: false,
        host: "183.132.2.19000",
      });

    useEffect(() => {
        const getSession = async () => {
            try {
                const d = await AuthSession.fetchDiscoveryAsync(domain);
               // console.log("Obj authSession",d)
                const authRequestOptions = {
                    prompt: AuthSession.Prompt.Login,
                    responseType: AuthSession.ResponseType.Code,
                    scopes: scopes,
                    usePKCE: true,
                    clientId: clientID,
                    redirectUri: redirectUrl,
                };
                const authRequest = new AuthSession.AuthRequest(authRequestOptions);
                //console.log("Auth request options:", authRequestOptions.scopes);
                setAuthRequest(authRequest);
                setDiscovery(d);
                //console.info("Discovery object:", d);

            } catch (error) {
                console.error(error);
            }
        };
        getSession();
    }, []);

    useEffect(() => {
        const getCodeExchange = async () => {
            try {
                console.log('entro')
                const tokenResult = await AuthSession.exchangeCodeAsync({
                    grant_type: "authorization_code",
                    code: authorizeResult.params.code,
                    client_id: clientID,
                    client_secret: clientSecret,
                    redirect_uri: redirectUrl,
                    extraParams: {
                        code_verifier: authRequest.codeVerifier || "",
                    },
                }, 
                discovery,
                console.log('segunda entrada')
                );
                console.log('redirect_uri:', redirectUrl);
               // console.log("Token scopes:", tokenResult);
                console.log('tecera entrada')

                const { access_token, refresh_token, expires_in } = tokenResult;
                console.log("Response accessToken from Graph v2", access_token);
                setToken(access_token)
                console.info(access_token)
                const response = await fetch(
                    `https://graph.microsoft.com/v1.0/me`,
                    {
                        headers: {
                            Authorization: `Bearer ${access_token}`,
                        },
                    }
                );
                console.log("Response from Graph API:", response);
                //givenName surname userPrincipalName id
                const responseJson = await response.json();
                // console.log("Access token scopes:", responseJson.scope);
                console.info(responseJson)
                const { givenName } = responseJson;

                setUsername(responseJson.givenName);
                // setEmail(responseJson.mail);
                // setId(responseJson.id);
                console.log(givenName)
                return navigation.navigate("HomeScreen");
            } catch (error) {
                console.error("error capa 1 "+error);
            }
        };

        if (authorizeResult && authorizeResult.type === "success" && authRequest) {
            getCodeExchange();
        }
    }, [authorizeResult, authRequest, discovery, clientID, redirectUrl, navigation]);

Problem to iterate through a nested JSON API with NEXTJS

I struggle to consume nested json API into with NEXTJS

Precisely, I fail to extract a nested dictionary from the API file, i.e. a dictionary in a dictionary.

In the example below I manage to extract and render correctly the first-level entries and that’s it more or less…

Ex: component name renders CardsPage

Which isn’t the case for the “cards” entries

Since the cards yield an array, I iterate with cards.map through it. Yet, besides the first level map item (here: type), all other fields remain blank, i.e I don’t call them correctly,

Any tip, advice on how to make it work, would be highly appreciated.

Herein, the CardsPage.js and the JSON file

The API entries in my JSON are:

Some entries were omitted for the sake of brevity:
CardsPage.js

...imports...

const CardsPage = ({ title, comments, cards }) => {
    return (
        <div className={s['CardsPage']}>
            <p> title:{title} </p>
            <RawHtml html={comments} />

        <div>
        {cards.map((card, key) => (
        <div>
            <p>{card.type}</p>
            <p>{card.value.title}</p>
            <p>{card.value.image.width}</p>...
            <img src={card.value.image.src} alt="BigCo Inc. logo"/>
       </div>
   ))}
   </div>

   </div>
   );
};

CardsPage.defaultProps = {
    title: '',
    cards: '',
    image: '',
};

CardsPage.propTypes = {
    title: PropTypes.string.isRequired,
    image: PropTypes.string.isrequired,
    ...
};

export default basePageWrap(CardsPage);

JSON API

{
    "component_name": "CardsPage",
    "component_props": {
        "title": "Sea creatures",
        "last_published_at": "2023-05-23T01:35:24.629463+02:00",
        "seo_title": "",
        "search_description": "",
        "seo": {
            "seo_og_image": null,
            "seo_html_title": "Sea creatures",
            "seo_meta_description": "",

...
  
        "cards": [
            {
                "type": "card",
                "value": {
                    "image": {
                        "id": 1,
                        "title": "whale",
                        "original": {
                            "src": "/wt/media/images/whale.original.jpg",
                            "width": 512,
                            "height": 512,
                            "alt": "whale"
                        },
                        "thumbnail": {
                            "src": "/wt/media/images/whale.2e16d0ba.fill-120x120.jpg",
                            "width": 120,
                            "height": 120,
                            "alt": "whale"
                        }
                    },
                    "card_title": "Whale",
                    "card_hint": "biggest"
                },
                "id": "c83003cf-4ee6-473f-a6b5-5a021bfc2fbd"
            },
           ...
        ],

    }
}

Why is my JavaScript code not retrieving data from a website’s feedback form into Google Sheets?

please help me to figure out with Google Sheets. This code seems to be working, but the data is not coming from the website’s feedback form.

I paste this code when creating an app in Google Sheets

var sheetName = 'Sheet1'
var scriptProp = PropertiesService.getScriptProperties()

function intialSetup () {
  var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet()
  scriptProp.setProperty('key', activeSpreadsheet.getId())
}

function doPost (e) {
  var lock = LockService.getScriptLock()
  lock.tryLock(10000)

  try {
    var doc = SpreadsheetApp.openById(scriptProp.getProperty('key'))
    var sheet = doc.getSheetByName(sheetName)

    var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0]
    var nextRow = sheet.getLastRow() + 1

    var newRow = headers.map(function(header) {
      return header === 'timestamp' ? new Date() : e.parameter[header]
    })

    sheet.getRange(nextRow, 1, 1, newRow.length).setValues([newRow])

    return ContentService
      .createTextOutput(JSON.stringify({ 'result': 'success', 'row': nextRow }))
      .setMimeType(ContentService.MimeType.JSON)
  }

  catch (e) {
    return ContentService
      .createTextOutput(JSON.stringify({ 'result': 'error', 'error': e }))
      .setMimeType(ContentService.MimeType.JSON)
  }

  finally {
    lock.releaseLock()
  }
}

I have this script on the site

<form name="submit-to-google-sheet">
     <input type="text" name="name" placeholder="Your Name" required>
     <input type="email" name="email" placeholder="Your Email" required>
     <textarea name="message" rows="6" placeholder="Your Message"></textarea>
     <button type="submit" class="btn btn2">Отправить</button>
</form>
<script>
    const scriptURL = 'https://script.google.com/macros/s/AKfycbxtQncRdZtIf1og4N5BxPijVDnQ_BadYpveI11qpkCH-f-378CfN_NqmlBEYYoYqYjB/exec';
    const form = document.forms['submit-to-google-sheet'];
    const msg = document.getElementById("msg")
    
    form.addEventListener('submit', (e) => {
        e.preventDefault();
        fetch(scriptURL, { method: 'POST', body: new FormData(form) })
            .then(response => {
                msg.innerHTML = "Message successfully"
                setTimeout(function(){
                    msg.innerHTML = ""
                }, 5000)
                form.reset()
            })
            .catch((error) => console.error('Error!', error.message));
    });
</script>

I also changed the function to insert the table ID, to no avail.

function initialSetup() {
    var activeSpreadsheet = SpreadsheetApp.openById("YOUR_SPREADSHEET_ID");
    scriptProp.setProperty("key", activeSpreadsheet.getId());
}

Select checkbox and update return invoice

I want to create a return invoice. I take the data from sql, and I have the possibility to change the quantity of each product that I want to return. In the image you can see that I selected record 2 and 4, but the script takes the first 2 records in ascending order and does the calculation for me.

I leave the script in php and js below, so you can help me correct it. I want to understand what I didn’t do well.

cal_final_total(count) is for calculate quantity price and tax

Thank you in advance for the answers.

enter image description here

$(document).on('change', function stornSelectedProducts() {
  var checkboxes = document.querySelectorAll('.checkbox');
  var count = 0;

  checkboxes.forEach(function(checkbox) {
    if (checkbox.checked) {
      count++;
      $('#total_item').val(count);
    }
  });
  cal_final_total(count);
});
update();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table class="table table-hover">
  <thead>
    <tr>
      <th width="1%">#</th>
      <th width="10%">Product code</th>
      <th width="40%">Description <span class="text-danger font-weight-bold">*</span></th>
      <th width="6%">Unit <span class="text-danger font-weight-bold">*</span></th>
      <th width="10%">QTY<span class="text-danger font-weight-bold">*</span></th>
      <th width="8%">Price <span class="text-danger font-weight-bold">*</span></th>
      <th width="8%">Price without VAT</th>
      <th width="8%">VAT</th>
      <th width="10%">Total with VAT</th>
      <th align="center"><input id="checkAll" class="form-control" type="checkbox" </th>
    </tr>
  </thead>
  @php($count = 0) @foreach($invoice as $row) @php($count++)
  <tbody>
    <tr>
      <td><span id="{{ $count }}">{{ $count }}</span></td>
      <td><input type="text" value="{{ $row->item_product_code }}" name="item_product_code[]" id="item_product_code{{$count}}" class="form-control" readonly></td>
      <td><input type="text" value="{{ $row->item_description }}" name="item_description[]" id="item_description{{$count}}" class="form-control" readonly></td>
      <td><input type="text" value="{{ $row->item_unit }}" name="item_unit[]" id="item_unit{{$count}}" class="form-control" readonly></td>
      <td><input type="text" value="{{ $row->item_quantity }}" name="item_quantity[]" id="item_quantity{{$count}}" class="form-control"></td>
      <td><input type="text" value="{{ $row->item_rate }}" name="item_rate[]" id="item_rate{{$count}}" class="form-control" readonly></td>
      <td><input type="text" value="{{ $row->item_actual_amount }}" name="item_actual_amount[]" id="item_actual_amount{{$count}}" class="form-control" data-srno="{{ $count }}" readonly></td>
      <td><input type="text" value="{{ $row->item_vat_amount }}" name="item_vat_amount[]" id="item_vat_amount{{$count}}" class="form-control" data-srno="{{ $count }}" readonly></td>
      <td><input type="text" value="{{ $row->item_final_amount }}" name="item_final_amount[]" id="item_final_amount{{$count}}" class="form-control" data-srno="{{ $count }}" readonly></td>
      <td align="center"><input class="checkbox" id="{{$count}}" type="checkbox" onChange="stornSelectedProducts()"></th>
    </tr>
  </tbody>
  @endforeach
</table>

<div class="row">
  <div class="col-xl-8 col-md-6 col-sm-6">
  </div>
  <div class="col-xl-4 col-md-6 col-sm-6">
    <table class="table table-hover">
      <tr>
        <td width=50%><input type="text" class="form-control" value="Total without VAT" readonly></td>
        <td width=50%><input type="text" name="total_amt_vat_0_val" class="form-control" value="0.00" id="total_amt_vat_0_val" readonly></td>
      </tr>
      <tr>
        <td width=50%><input type="text" class="form-control" value="VAT" readonly></td>
        <td width=50%><input type="text" name="total_amt_vat_val" class="form-control" value="0.00" id="total_amt_vat_val" readonly></td>
      </tr>
      <tr>
        <td width=50%><input type="text" class="form-control" value="Total with VAT" readonly></td>
        <td width=50%><input type="text" name="total_amt_val" class="form-control" value="0.00" id="total_amt_val" readonly></td>
      </tr>
      <tr>
      </tr>
    </table>
  </div>
</div>

Sugestoes de api Maps para calculo de distancia [closed]

Estou fazendo um projeto em php onde preciso calcular a distancia entre o endereco cadastrado no caso a Loja e o endereco do cliente, e armazenar essa distancia, queria usar a api do google mas devidos a alguns problemas ela nao e viavel a mim, queria pedir sugestoes a voces onde a api me permita fazer isso alem de ser gratuita

tentei usar a api do mapquest so que nao to tendo precisao no dados alem de problemas para implementar

Text outside group is being cut/clipped

In fabricjs (v5.3.0) in angular app I have a fabric.Group that contains 12 Rects and a fabric.Text.

let group = fabric.Group(rectangles, {});
let text = new fabric.Text('This is very long text that is being cut on zoom', {
      top: -(group.height / 2 + offset),
      originX: 'center',
      originY: 'center',
    });

group.add(text);

As you can see text is added after creating a group so the group dimensions/bounds are not changed and this is expected behaviour. Dimensions cannot change otherwise if we will increase group dimension by text dimension, the center point of the group will be in different place (it will affect many other mechanisms that I implemented so I cannot do this)
But when text is long or the canvas zoom is huge the text is being cut horizontally and vertically.
Why it cannot be positioned ‘absolute’ without any issues?

text is being cut

I tried different font families, setting objectCaching to true/false, manipulating clipPath of the text as well as group but I am not sure if this is the case here.

Suitescript – Using a dynamically created “fieldId” in the script

I want to dynamically create a field id based upon results. I have a very basic script showing what I am trying to do. It continues to not retrieve information. I have tried using + instead of concat (”custitem’ + testtext + ”’). When I log the field name – it shows correctly ‘custitemdoe_jane’.

You can see the script shows using the formula in two different ways. Can this be done??

 /**
 * This script looks for RTAs - updates the purchase Order and the CT record
 * 
 * @NApiVersion 2.x
 * @NScriptType ScheduledScript
 * @NModuleScope SameAccount
 */
 
define(['N/file', 'N/search', 'N/record', 'N/format', 'N/email'],
        
function(file, search, record, format, email) {
    
    function execute(scriptContext) {
    var texty = ''custitem';
    var testtext = 'doe_jane';
    var texty3 = ''';
    var fieldname = texty.concat(testtext);
    var fieldname = fieldname.concat(texty3);
    
    log.debug('fieldname', fieldname);

// end result here is ‘custitemdoe_jane’ with the quotes

    var itemfix = record.load({
        type: record.Type.INVENTORY_ITEM, 
        id: 488, 
        isDynamic: false
        });
            
        var values = itemfix.getText({fieldId: fieldname});   
        var values2 = itemfix.getValue({fieldId: fieldname});    
        log.debug('values', values);
        log.debug('values', values2);

       var values3 = itemfix.getText({fieldId: fieldname.concat(texty3)});   
        var values4 = itemfix.getValue({fieldId: fieldname.concat(texty3)});    
        log.debug('values', values3);
        log.debug('values', values4);
        

// all of these above are blank

        itemfix.save({
            enableSourcing: true
        });             
        }
        
return {execute: execute};
    
});

Redirecting to relative URL stripping some of the path

I have a page located at https://example.com/a/b/c/d/e/page?query=string and I’d like to redirect the user to https://example.com/a/b/c/d/e/otherpage. I was expecting this to work:

window.location.href = "otherpage"

but that redirects to https://example.com/a/b/otherpage. I thought a relative URL like that would use a URL with the contents after the last slash replaced with the new URL?

PUT & DELETE not working for node.js mongodb project

I am unable to PUT or DELETE data that I have sent to MongoDB. I have tried looking for any bugs but I cannot seem to find any and do not what may be causing this error. GET and POST work fine.

I will post my controllers and views.

controllers/cards.js

const express = require('express')
const cardsRouter = express.Router()
const auth = require('../middleware/auth')
const User = require('../models/user')


// DELETE
cardsRouter.delete('/cards/:id', auth.isAuthenticated, async (req, res) => {
  try {
    const user = await User.findById(req.user._id);
    user.cards.pull(req.params.id);
    await user.save();
    res.redirect('/dashboard');
  } catch (err) {
    res.status(500).send(err);
  }
});


// UPDATE
cardsRouter.put('/cards/:id', auth.isAuthenticated, async (req, res) => {
  try {
    const user = await User.findById(req.user._id);
    const card = user.cards.id(req.params.id);
    card.overwrite(req.body);
    await user.save();
    res.redirect('/dashboard');
  } catch (err) {
    res.status(500).send(err);
  }
});


// EDIT
cardsRouter.get('/:id/edit', auth.isAuthenticated, async (req, res) => {
  try {
    const user = await User.findById(req.user._id);
    const card = user.cards.id(req.params.id);
    res.render('../views/cards/edit', { card });
  } catch(err) {
    res.status(500).send(err);
  }
});


// SHOW
cardsRouter.get('/cards/:id', auth.isAuthenticated, async (req, res) => {
  try {
    const user = await User.findById(req.user._id);
    const card = user.cards.id(req.params.id);
    res.render('cards/show', { card });
  } catch (err) {
    res.status(500).send(err);
  }
});



module.exports = cardsRouter

views/cards/edit.ejs

<!DOCTYPE html>
<html lang="en">
<%- include('../partials/head.ejs') %>
<body>
  <%- include('../partials/header') %>
  <h2>Edit Page</h2>

  <form action="/cards/<%= card._id %>?_method=PUT" method="POST" method="post">
    <input placeholder="Noah and The Great Flood" type="text" name="title"><br>
    <input placeholder="https://www.youtube.com/watch?v=KOUV7mWDI34" type="text" name="link"><br>
    <input placeholder="Genesis 5:1" type="text" name="scripture"><br>
    <textarea
      placeholder="Here we can learn about how God has had mercy on humanity by giving it a second opportunity..."
      name="description" cols="30" rows="10"></textarea><br>
      <input type="submit" value="Submit Changes">
  </form>



</body>
</html>

I also have another section for posts that is doing the same exact thing.

controllers/posts.js

const express = require('express')
const postsRouter = express.Router()
const auth = require('../middleware/auth')
const Post = require('../models/post')
const User = require('../models/user')

// READ
postsRouter.get('/posts/new', auth.isAuthenticated, (req, res) => {
  res.render('posts/new')
})

// DELETE
postsRouter.delete('/posts/:id', auth.isAuthenticated, async (req, res) => {
  try {
    const post = await Post.findById(req.params.id);
    
    if (req.user._id.equals(post.createdBy._id)) {
      await Post.findByIdAndDelete(req.params.id);
    }
    
    res.redirect('/dashboard');
  } catch (err) {
    res.status(500).send(err);
  }
});


// UPDATE
postsRouter.put('/posts/:id', auth.isAuthenticated, async (req, res) => {
  try {
    const user = await User.findById(req.user._id);
    const post = user.posts.id(req.params.id);
    post.overwrite(req.body);
    await user.save();
    res.redirect('/dashboard');
  } catch (err) {
    res.status(500).send(err);
  }
});


// CREATE/POST
postsRouter.post('/posts', async (req, res) => {
  try {
    req.body.createdBy = req.user._id;
    const post = await Post.create(req.body);
    res.redirect('/dashboard');
  } catch(err) {
    res.status(500).send(err);
  }
});


// EDIT
postsRouter.get('/posts/:id/edit', auth.isAuthenticated, async (req, res) => {
  try {
    const user = await User.findById(req.user._id);
    const post = user.posts.id(req.params.id);
    res.render('posts/edit', { post });
  } catch (err) {
    res.status(500).send(err);
  }
});



// SHOW
postsRouter.get('/posts/:id', async (req, res) => {
  try {
    const post = await Post.findById(req.params.id).populate('createdBy').exec();
    res.render('posts/show', { post });
  } catch(err) {
    res.status(500).send(err);
  }
});



module.exports = postsRouter

views/edit.ejs

<!DOCTYPE html>
<html lang="en">
<%- include('../partials/head') %>
<body>
  <%- include('../partials/header') %>
  <h2>Edit Page</h2>

  <form action="/posts/<%= post._id %>?_method=PUT" method="POST" method="post">
    <input placeholder="Noah and The Great Flood" type="text" name="title"><br>
    <input placeholder="https://www.youtube.com/watch?v=KOUV7mWDI34" type="text" name="link"><br>
    <input placeholder="Genesis 5:1" type="text" name="scripture"><br>
    <textarea
      placeholder="Here we can learn about how God has had mercy on humanity by giving it a second opportunity..."
      name="description" cols="30" rows="10"></textarea><br>
      <input type="submit" value="Submit Changes">
  </form>



</body>
</html>

Please let me know if anyone has any ideas, I would really appreciate. If the code blocks are too much at least point me in the direction of where to look more specifically. Thank you!

How to override auto inline styles from Three.js on canvas element for page background?

i have created a scene with three.js and i want to use it as the background for my page but i can’t for the life of me get the canvas element to move without chopping off half of my page.

i have gotten rid of every bit of css i had so there are no potential conflicts. it seems like three.js has some auto styling happening inline on the canvas element, but i cant override it.

devtools, only place i can see the auto styling thats being applied

i have tried using !important for the properties i was trying to override, i’ve tried styling the element inline myself. and i’ve obviously tried everything i can think of in a separate stylesheet.
i also tried moving all of my three.js into its own file so that i could try instead.

Updating a total after removing from the cart

Good evening guys, this is my first time using stackflow, so please be kind, I have been working on a restaurant order type app for staff, and have can’t seem to find a solution without deleting loads of code. When I delete an item from the cart I would like the total to update, iv tried different ideas for other peoples problems but can’t seem to get it to work, and thus im going around in circles and not seeing the solution, I know there is probably a simple solution but any help would be much appreciated,
javascript and html below
cheers in advance



let subtotal = 0;

function Delete(currentEl){
  currentEl.parentNode.parentNode.removeChild(currentEl.parentNode);
   }

const calculateserviceCharge = subtotal => {
    const serviceCharge = subtotal*.12;
    const formattedserviceCharge = serviceCharge.toFixed(2);
    return formattedserviceCharge;
};

const calculateTotal = subtotal => {
    const serviceCharge = calculateserviceCharge(subtotal);
    const total = parseFloat(subtotal) + parseFloat(serviceCharge);
   
    
    const formattedTotal =total.toFixed(2);
    
    return formattedTotal;
    
};



                    $('.btn').on('click', function () {
                        const title = $(this).data('title');
                        const price = $(this).data('price');
                        
                        const element = `
                       <p class="cart-item-heading ">${title} £${price}   <button id="delete" onclick="Delete(this);">X</button>`;
                       
                        $('.cart-items').append(element);
                       
                        
                        subtotal = subtotal + price;
                        
                        const formattedSubtotal = subtotal.toFixed(2.3);
                        const serviceCharge = calculateserviceCharge(subtotal);
                        const total = calculateTotal(subtotal);
                        
                        
                       
                        
                        
                 
                        

                        $('.cart-math').html(`
                        <p class="cart-math-item">
                        <span class="cart-math-header">Subtotal:</span>
                        <span class="g-price subtotal">
                        <break>
                        £${formattedSubtotal}</span>
                        </p>
                        <p class="cart-math-item">
                        <span class="cart-math-header">Service Charge(12%):</span>
                        <span class="g-price tax">£${serviceCharge}</span>
                        </p>
                        <p class="cart-math-item">
                        <span class="cart-math-header">Total:</span>
                        <span class="g-price total">£${total}</span>
                        </p>
                        
                        `);
                    
                      
                  
                    });
<button class='hide-3'id="hide" style="background-color: #edb90f">Close</button>
    <div class="mains"id="subject">

    <button
        class="btn" 
        style="background-color: #edb90f"
        data-title="Duck" 
        data-price="21.95">Duck
    </button>
    <button 
        class="btn" 
        style="background-color: #edb90f"
        data-title="Chicken" 
        data-price="18.95">Chicken
    </button>
    <button
        class="btn"
        style="background-color: #edb90f"
        data-title="Salmon Fillet" 
        data-price="19.95">Salmon Fillet
    </button>
    <button 
        class="btn" 
        style="background-color: #edb90f"
        data-title="Orzotto" 
        data-price="12.95">Orzotto
    </button>
    <button 
        class="btn" 
        style="background-color: #edb90f"
        data-title="Vegan Burger" 
        data-price="15.45">Vegan Burger
    </button>
    <button 
        class="btn" 
        style="background-color: #edb90f"
        data-title="Sea Bass" 
        data-price="16.95">Sea Bass
    </button>
    <button 
        class="btn" 
        style="background-color: #edb90f"
        data-title="Classic Burger" 
        data-price="15.45">Classic Burger
    </button>
    <button 
        class="btn" 
        style="background-color: #edb90f"
        data-title="Tuna" 
        data-price="22.95">Tuna
    </button>
    <button 
        class="btn" 
        style="background-color: #edb90f"
        data-title="Whole Sea Bream" 
        data-price="49.95">Whole Sea Bream
    </button>

    </div>
  </dialog>

this will probably be an easy solution to most but I just can’t see it at the moment

How to replace a value of the element in soap request in Api Connect using Gateway scripting

Below is input request that I have saved in the Request variable and saved the response string in the ResponseString variable. Now I need to replace the ResponseString variable value with Payload element value in the input request, please refer to the below request for reference. All helps are much appreciated!

var Request = apim.getvariable(‘originalRequest’);

var ResponseString = ‘DataIndex_12345’;

Input Request:

<soap:Envelope xmlns:or="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
   <soap:Body>
      <or:Request>
         <Sender>Mark</Sender>
         <Receiver>Steve</Receiver>
         <Payload>Data</Payload>
      </or:Request>
   </soap:Body>
</soap:Envelope>

Expected Output Request:

<soap:Envelope xmlns:or="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
   <soap:Body>
      <or:Request>
         <Sender>Mark</Sender>
         <Receiver>Steve</Receiver>
         <Payload>DataIndex_12345</Payload>
      </or:Request>
   </soap:Body>
</soap:Envelope>

Clash Royale API message: ‘Invalid authorization’

I am trying to use the official API of the game Clash Royale, but it keeps returning error even tho I’ve done everything right.

data: { reason: 'accessDenied', message: 'Invalid authorization' }

My code is right here:

"Authorization": "Bearer MyTokenHere"

I’ve replaced MyTokenHere with my API token, I also added my IP to allowed IPs section. But it still keeps not working with the error above.

I’ve done all that I’ve mentioned above.

Error while returning data provided by an user

I’m a beginner to back-end programming and today I stumbled upon an issue, perhaps I could use some help.

I created a website that displays recipes from an API where you can also create your own recipes by clicking on the Create New Recipe button which leads you into a form, after submitting basic info such as recipe name, summary and step-by-step instructions it then displays a message reading Recipe added successfully.

You can then search a recipe by submitting its name on a input and it should return a card containing all the info you submitted about that recipe.

My issue is that (1 It is not returning a card and (2 I opened Chrome DevTools and it displays an error: 404 Recipe not found

Here is a link source to my GitHub repo: Hi! I’m a link.

Feel free to ask questions to get this problem solved, it’s a project due to this Friday 🙂