I'm setting up the client on my React Native project
let client = new LDClient();
let config = { "mobileKey": "YOUR_MOBILE_KEY" };
let user = { "key": "user_key" }; // where do I find this info?
await client.configure(config, user);
I'm currently getting as a return value to this {"_U": 0, "_V": 0, "_W": null, "_X": null} assuming that's because of the missing user_key.
Where can I find my user_key?
user_key is a unique string that identifies the user loading the website. It's something that you need to provide. LaunchDarkly needs to be able to differentiate your users in order to do things like partial rollouts.
I believe you got the user_key from launchDarkly or you can check it in their API documentation on how to get the user_key
As for the problem where you get {"_U": 0, "_V": 0, "_W": null, "_X": null}, this is what you get when you log Promise before it resolve.
Related
I have to fetch data from a prestashop, and it has worked until now. They have upgraded their prestashop but haven't given me more details.
When I call: https://realshopname/api/categories?display=full&limit=0,50
which works fine on other prestashop installations and also this one, before they made an update. Now I get the following error
PHP Warning #2] Declaration of Product::addAttribute($price, $weight,
$unit_impact, $ecotax, $id_images, $reference, $delivery_label,
$ean13, $default, $location = NULL, $upc = NULL, $minimal_quantity =
1, array $id_shop_list = Array, $available_date = NULL, $quantity = 0,
$isbn = '', $low_stock_threshold = NULL, $low_stock_alert = false)
should be compatible with ProductCore::addAttribute($price, $weight,
$unit_impact, $ecotax, $id_images, $reference, $ean13, $default,
$location = NULL, $upc = NULL, $minimal_quantity = 1, array
$id_shop_list = Array, $available_date = NULL, $quantity = 0, $isbn =
'', $low_stock_threshold = NULL, $low_stock_alert = false)
(/var/www/realshopname/public_html/override/classes/Product.php, line
0)"
As far as I guess, the error is on their shop, but how can I help the shop in figuring out what is wrong.
The issue appears to come because there is an override file (probably needed by some module to extend core functionalities) :
/var/www/realshopname/public_html/override/classes/Product.php
that conflicts with webservices.
Have an inspection on this file, you'll probably find in a comment the module that uses this override. Then check if module is still needed , in this case an update is required to make it compliant with new version. Otherwise uninstall the module and you should be all set.
We were testing an API and recently got an issue, some of the customers cannot log in to the website.
We found the issue and it is because of Duplicate keys in the API response, it is giving response even if the API contains the duplicate key.
So tests are not helping for the duplicate key conditions,So can anyone please help me or guide how I can find whether there is a duplicate element in the API response.
Tool: postman
Below is the sample API output,
In the below JSON output from API we can find there are duplicates for "operatingSystem",like this duplicate key is coming for different elements.
Since there is no way to debug the API for a while due to some reasons,so need to find out these duplicate cases.
Any idea or suggestions will be much appreciated.Thanks in advance.
JSON
eg: {
"code": 2,
"deviceId": "ID",
"deviceName": "Test",
"platform": "x64",
"operatingSystem": "test",
"operatingSystem": "test",
"gde": 000,
"productVersion": "0.0",
"build": "00000",
"receipt": null
}
How could we handle such a situation. Do we have any method to automate/test this case?
Here's something you can try although it's a bit convoluted. pm.response.json() will normalize the response and remove any duplicates i.e. you won't be able to detect any. So what you can do is take the response in text then manipulate it into a list and look for duplicates there. I used a map object so that if the map already contains a given key then set a flag and fail the test.
This is not thoroughly tested but it should give you an idea or at least a starting point to tackle the problem:
var jsonBody = pm.response.text();
var str = jsonBody.substring(1, jsonBody.length-1);
var keyArr = str.split(",");
var keyMap = {};
var foundDups = false;
for (var i = 0; i < keyArr.length; i++) {
var key = keyArr[i].split(":")[0];
if(!(key in keyMap)) {
keyMap[key] = key;
console.log("added key " + key);
}
else {
console.log("found duplicate: " + key);
foundDups = true;
break;
}
}
pm.test("Look for dups", function() {
pm.expect(foundDups).to.eql(false);
});
I am not sure if I am making a mistake or if possibly this is related to the same issue reported here:
Google Sheets API V4 - Autofill Error - No grid with id: 0
I am getting:
HttpError 400
"Invalid requests[0].addProtectedRange: No grid with id: 1"
Code is something like this (additional addProtectedRange objects removed)
def add_protected_ranges(spreadsheet_id):
service = get_sheets_service()
requests = [
{
"addProtectedRange": {
'protectedRange': {
"range": {
"sheetId": 1,
"startRowIndex": 0,
"endRowIndex": 0,
"startColumnIndex": 0
},
"description": "Headers must not be changed",
"warningOnly": True
}
}
}
]
body = {
'requests': requests
}
response = service.spreadsheets().batchUpdate(spreadsheetId=spreadsheet_id,
body=body).execute()
Had kind of the same issue. I was confusing the sheet id with sheet index.
Easiest way to find the sheet id is in the browser URL when you open the spreadsheet / sheet: https://docs.google.com/spreadsheets/d/{spreadsheetId}/edit#gid={sheetId}
If you're looking for a more programmatic way you find that property on the SheetProperties.
I know that's an old question but I was looking for it too. You're looking for:
res.data.sheets[].properties.sheetId
To get the sheetId (not the spreadsheetId) use:
sheets.spreadsheets.get({
spreadsheetId
}).then(res => {
console.log("All the sheets:");
for(i in res.data.sheets) {
let title = res.data.sheets[i].properties.title;
let id = res.data.sheets[i].properties.sheetId;
console.log(title + ': ' + id);
}
});
Make sure that there is a workbook with the id 1 in your spreadsheet. In google sheet, a spreadsheet can contain multiple worksheet(grid), there is a unique id for each of the worksheet(grid).
I'm trying to create a pjmedia recorder but after the creation the status is 12001 instead of PJSUCCESS(0).
pj_status_t function()
{
pjsua_recorder_id recorder_id;
pj_status_t status;
pj_str_t fileName =pj_str("mysong.wav");
status = pjsua_recorder_create(&fileName, 0, NULL, 0, 0, &recorder_id);
if (status != PJ_SUCCESS)
return status;
}
Thanks.
My mistake was that I didn't specify the full path of the file and it didnt get permission to write the file in that location.
I am trying to implment the XMPP Client. I am using BOSH Connection manager and can run the Strophe.connect but not Strophe.Attach. I have tried incrementing the RID, but no effect.. Any help please ? There is no error here, but the Strophe.Status.CONNECTED is never reached via the attach method and so I cannot send IQ or Presence.
Here is my code
try
{
var cookieJid = $.cookie("jid");
var cookieSid = $.cookie("sid");
var cookieRid = $.cookie("rid");
var connt = new Strophe.Connection("http://localhost:7070/http-bind/");
connt.attach(cookieJid, cookieSid, cookieRid + 1, function(status)
{
if (status === Strophe.Status.CONNECTED)
{
alert ("hola connected");
$("#userName").append("hola connected : " + connt.jid );
var iq = $iq({type: 'get'}).c('query', {xmlns: 'jabber:iq:roster'});
connt.sendIQ(iq, handleRoster);
connt.send($pres());
}
});
}
catch (e)
{
$("#userName").append("Pinky error is " + e);
}
Edit
Thanks Eric and Charlie.
So I took the latest Strophe.js and now Attached status does work.
But the connection disconnects instantaneously. I am not even able to fetch the Roster.
We can possibly do every thing with Connection.attach() as we would with connection.connect(), right?
Any thoughts?
Change the line:
if (status === Strophe.Status.CONNECTED)
...to...
if (status === Strophe.Status.CONNECTED || status === Strophe.Status.ATTACHED)
Are you using the latest Strophe library? In the version I'm using, I see that the status can be these values:
Status: {
ERROR: 0,
CONNECTING: 1,
CONNFAIL: 2,
AUTHENTICATING: 3,
AUTHFAIL: 4,
CONNECTED: 5,
DISCONNECTED: 6,
DISCONNECTING: 7,
ATTACHED: 8
}
Make sure you convert your cookieRid to a Number by using new Number(cookieRid). Otherwise, when you do +1 on it, you will get "####1".
You can test this out for yourself in Javascript:
var s = "123";
alert(s+1); // "1231" and not "124"
Also, as Eric answered, there is a status ATTACHED so you need to handle that event.