…using the unittest.mock module. This module contains a number of useful classes and functions, namely the patch function (as decorator and context manager) and the MagicMock class. These two components are very important in achieving mocking in Python.A mock function call usually returns a predefined value immediately. A mock object's…
…using the created REST API endpoint.In this tutorial, you'll be creating a new component called AddPostComponent to provide the user interface to add a new blog post to the MongoDB database.Getting StartedLet's get started by cloning the source code from the previous part of the tutorial series.git clone https://github.com/royagasthyan/ShowPost AddPostNavigate…
…In the previous part of this tutorial series you learnt how to create the add post component to add new blog posts. You learnt how to create the REST API endpoint to add a new post to the MongoDB database.In this part of the tutorial series, you'll learn how to…
…using the Laravel Passport library. We’ll go through the necessary server configurations along with a real-world example to demonstrate how you could consume OAuth2 APIs. I assume that you’re familiar with the basic OAuth2 concepts and flow as we’re going to discuss them in the context of Laravel. In fact,…
…using the Mongoose client.mongoose.connect(url, { useMongoClient: true }, function(err){ // connection established });You'll make use of the findByIdAndRemove method to find the blog post using the id and delete it. Once the blog post has been deleted successfully, you'll return the status as a response. Here is how the REST…
…using WebSockets. In this example, the client is a web browser and the server is the Node.js application. The server can have multiple clients connected to it at any given time. Once the connection has been established, the server can send messages to all of the clients or an individual…
…using customizable HTML/CSS templates. Best features: over 50 pre-built templates included highly customizable layout accepts any HTML5 form elements default options ready for Bootstrap 4 email sending with advanced options Material Design and Foundation forms and more With loads of options for creating a variety of elegant contact forms and…
…using this library is easy. ProgressBar.js is supported in all major browsers, including IE9+, which means that you can use it in any website you are creating with confidence. You can get the latest version of the library from GitHub or directly use a CDN link to add it to…
…using npm or bower, you can install it by running the following commands: npm install sweetalert2 bower install sweetalert2 You can also get a CDN link for the latest version of the library and include it in your webpage using script tags: <script src="https://cdn.jsdelivr.net/npm/sweetalert2@10.10.1/dist/sweetalert2.all.min.js"></script> Besides the JavaScript file, you'll also…
…using arrow syntax const curriedSum = a => b => a+b curriedSum(5)(4) //9 The function accepts just one argument and returns a function that takes in another argument, and this continues until all the arguments are satisfied. curriedSum // (a) => (b) => a+b curriedSum(4) // (b) => 4+b curriedSum(4)(5)…