from the below video post/reel, Bhai ji explaining when one will face danger and why one not if he his real Spritual Guru or motivational speaker.
Because, when one will not face danger or faced danger, he will have not touch the real issues of India who all have holding the India from within by using masked face of religion, politicians and what not.
Here I would like to share with you a very handy and new innovative approach using ES6 Tag Literals template to ease of creating the base URL’s for use a single source of truth defined as library constants or utility code to refer as the single page application grows.
Let’s get hand dirty and mind free from hassle of maintaining and forming lines cluttered code and creating mess in many files as web application grows.
Hope you understand what I mean, developers get frustrated to follow the best practice as in tight project deadlines,
Heads up on I am currently using 2Factor.in endpoints in this post as I were using part of the project implementation, we will head in list out numbers as steps needs to follow for the quick implementation:
We will save API key and API base URL in env file, (hope you are aware were it will lies in your project code, basically it lies at the core level of project director with named and with extension exactly, .env
3. Next we need to import publicRuntimeConfig object in our constants(.js) file
import { publicRuntimeConfig } from "./env.settings";
I am importing from .env.settings files which is actually using nextjs getConfig method to export publicRuntimeConfig variable, I am skipping that step to show here, once you search for docs on next/config you will get an idea what we are doing here.
4. Main part here it comes in contants.js file:
export const f2param1 = (param) => param || 1234657890;
export const f2param2 = (param) => param || "myTemplateName-OTP";
export function tagTemplate2FactorAPI(strings, param1, param2) {
const { SITE_2FACTORIN_API_BASE_URL, SITE_2FACTORIN_API_KEY } = publicRuntimeConfig;
const prefixBaseUrl = SITE_2FACTORIN_API_BASE_URL + SITE_2FACTORIN_API_KEY + '/';
let str0 = strings[0] || ""; // "That "
let str1 = strings[1] || ""; // " is a "
let str2 = strings[2] || ""; // "."
// We can even return a string built using a template literal
return `${prefixBaseUrl}${str0}${param1 || ''}${str1}${param2 || ''}${str2}`;
}
export const factor2API_Endpoint = {
CHECK_OTP_SMS_BALANCE: `BAL/SMS`,
SEND_OTP_SMS: tagTemplate2FactorAPI`SMS/${f2param1()}/AUTOGEN`,
SEND_OTP_SMS_TEMPLATE: tagTemplate2FactorAPI`SMS/${f2param1()}/AUTOGEN/${f2param2()}`,
SEND_VERIFY_SMS: tagTemplate2FactorAPI`SMS/VERIFY/${f2param1()}/${f2param2()}`,
CHECK_TRANS_SMS_BALANCE: `/ADDON_SERVICES/BAL/TRANSACTIONAL_SMS`,
SEND_TRANS_SMS: `/ADDON_SERVICES/SEND/TSMS`,
SEND_TRANS_SMS_DYNAMIC_TEMPLATE: `/ADDON_SERVICES/SEND/TSMS`,
};
console.log(factor2API_Endpoint.SEND_OTP_SMS);
console.log(factor2API_Endpoint.SEND_OTP_SMS_TEMPLATE);
console.log(factor2API_Endpoint.SEND_VERIFY_SMS);
This is how the final code looks, but there is a catch in this code, just need to handle of passing the params dynamically to the constants property of the object, otherwise with the fixed 2 params in same file would do the trick.
Will share once I got the way of passing dynamic params values to object property in template literal invocation line.
—— Here I found it the other approach —- Edited: 00:44 (after few mins of publishing this post after above approach shared 🙂 )
export function tagTemplate2FactorAPI(strings, ...keys) {
const { SITE_2FACTORIN_API_BASE_URL, SITE_2FACTORIN_API_KEY } = publicRuntimeConfig;
const prefixBaseUrl = SITE_2FACTORIN_API_BASE_URL + SITE_2FACTORIN_API_KEY + '/';
return (function (...values) {
let dict = values[values.length - 1] || {};
let result = [strings[0]];
keys.forEach(function (key, i) {
let value = Number.isInteger(key) ? values[key] : dict[key];
result.push(value, strings[i + 1]);
});
result.unshift(prefixBaseUrl); //added this line to prefix with base url path
return result.join('');
});
}
export const factor2API_Endpoint = {
CHECK_OTP_SMS_BALANCE: `BAL/SMS`,
SEND_OTP_SMS: tagTemplate2FactorAPI`SMS/${0}/AUTOGEN`,
SEND_OTP_SMS_TEMPLATE: tagTemplate2FactorAPI`SMS/${0}/AUTOGEN/${1}`,
SEND_VERIFY_SMS: tagTemplate2FactorAPI`SMS/VERIFY/${0}/${1}`,
CHECK_TRANS_SMS_BALANCE: `/ADDON_SERVICES/BAL/TRANSACTIONAL_SMS`,
SEND_TRANS_SMS: `/ADDON_SERVICES/SEND/TSMS`,
SEND_TRANS_SMS_DYNAMIC_TEMPLATE: `/ADDON_SERVICES/SEND/TSMS`,
};
console.log(factor2API_Endpoint.SEND_OTP_SMS(12311312, 'newTemplate-newOTP'));
console.log(factor2API_Endpoint.SEND_OTP_SMS_TEMPLATE(5656565, 'newTemplate-newOTP'));
console.log(factor2API_Endpoint.SEND_VERIFY_SMS(456646545, 'newTemplate-newOTP'));
Here is the quick solution I found and worked for me, hope it helps you too in some scenario we might mistaking
As in the (a) was getting null as a data response in the react child component (where the text shown “Reset linked expired…”) , where actually data was updating from parent component and passed to react child component named <ResetPasswordForm … /> as ‘data’ as a prop, here its full code look like:
Solution 1 : To fix the issue of null, I have to remove the wrapping GlobalCookieContextProvider component as I was not passing any prop to it and also I have no use in this Reset Password Main component, so after removing the wrapping Provider component it worked like as expected, Boom!.
Results of JSON output attached to the form
Hence start receiving data from parent react component when state change updated dynamically from URL query params as expected.
But wait, Solution 1, was not working still as expected in certain refreshes, then work around did and moved the all query params check code from nextjs page component to its child level component named ResetPasswordForm component and everything finally working as expected again.
Hope you enjoyed the post, let me know in comments if confused you, will try to re-try to post again.
Happy we learning!
Conclusion
First found the wrapping un-used React Provider component, causing a stop of re-ending of react child component when parent component state update done, but after some further testing its was still breaking, final solution found in moving the router query params check and updating state into the first level child component itself which does the expected checks in useEffect() and render the component fairly with the expected results on query fetch done.
For the simple question here is the simple answer:
as we know 1kg = 1000 grams
Formular for easy getting grams rate from per kg is looks like:
So g grams is g/1000 kg and the price will be g/1000 * r (rupees/kg) or rupees/kg= g*r/1000
For example to calculate the rate of 100 grams from per kg.
Let say we have some wheat item whose rate is 1 kg = 20 rupees and we have to calculate the rate for 100 grams wheat? 100/1000 * 20 = 2 rupees or 100 * 20/1000 = 2 rupees
First sorry for such long question in the heading. Will start with small story and then right to the solution fix I found.
Facing issue of getting id of Joined table in my current laravel project, where I need a Id column value from the Main table not the one which I used to inner join for the records to pull in.
Here is my existing query of Laravel returning t he id of customer table where I was looking id of Bill’s Table:
So the right solution is at the last line in the above code, please carefully see the get() function array parameters; I switched them, so it finally returns the id values of bills not of customer table. (as customer table also id column which matches with bill’s table column)
It looks complex if you pay a little bit close look, its most simple.
You may extend more with if else or else conditions. I just kept to that extend as not require for me any else condition for error handling or something else to output.
If you are looking for 3D print service and if you got the file and need a print, you can reach out here 3dprint@doableyo.com.
They respond usually on weekends for the delivery of print but you can write them anytime for any queries, they are new in 3D printing 👣🐾 but they can solve and helpful for the problem you might have.
As of part of learning and development of laravel project I was simply looking syntax how to call laravel controller method in another controller.
Here is some tips and example:
Make sure you declared function as with public keyword while defining any method/function in controller.
Method updateMethod defined in controller called DoctorController.php as follow:
public function updateMethod($request, $id) {
// echo $id;
. . . // more lines of your code here
}
Secondly calling updateMethod in controller called DoctorApiController.php
public function updateDoctor(Request $request, $id) {
if (Doctor::where('id', $id)->exists()) {
$result = (new DoctorController)->updateMethod($request, $id);
return response()->json([
"message" => "Doctor updated successfully"
], 200);
} else {
return response()->json([
"message" => "Doctor not found"
], 404);
}
}
If you got any error with DoctorController or your Controller class name not found or any such please add: use App\Http\Controllers\DoctorController; on top of the file.
This was the one way to simply call method of laravel one controller to other.
Lot of us facing currently down issue from Whatsapp, Facebook and Instagram:
Here are there tweets on issues:
Instagram
Facebook
Whatsapp
So we don’t need to worry much and relax our nerves and mind and let the giants work on the issue until than we can take some good good nap for living life’s.