Posts

Showing posts from January, 2024

Today I have learned Put and Post API in javascript

Image
 Put and Post API in javascript: The POST method The POST method sends data to the server and creates a new resource. The resource it creates is subordinate to some other parent resource. When a new resource is POSTed to the parent, the API service will automatically associate the new resource by assigning it an ID (new resource URI). In short, this method is used to create a new data entry.   postcall = async () => {     const headers = {       "Content-Type" : "application/json" ,       Authorization : `Bearer ${this . state . accesstoken } ` ,     };     const Checkdata = {       email : this . state . email ,       password : this . state . password ,     };   const res = await axios       . post ( ` ${ ip } /post` , Checkdata , {         headers : headers ,       })       . then (( res...

Today I have learned API in javascript

Image
  The GET method The GET method is used to retrieve data from the server. This is a read-only method, so it has no risk of mutating or corrupting the data. For example, if we call the get method on our API, we’ll get back a list of all to-dos.   getcall = async () => {         //api call to get all cpt data         const headers = {           "Content-Type" : "application/json" ,           Authorization : `Bearer ${this . state . accesstoken } ` ,         };         // eslint-disable-next-line         const res = await axios           . get ( ` ${ ip } /head` , { headers : headers })           . then (( res ) => {             this . setState ({               cptdata : res . data . cpt ,   ...

Today I have solved the problem in javascript

 Implement a queue using a set of fixed-length arrays. The queue should support enqueue, dequeue, and get_size operations. const queue = FixedArrayQueue(5); queue.enqueue(1); queue.enqueue(2); queue.enqueue(3); function FixedArrayQueue(capacity) {   const queue = new Array(capacity);   let front = 0;   let rear = 0;   let size = 0;   function isFull() {     return size === capacity;   }   function isEmpty() {     return size === 0;   }   function enqueue(item) {     if (isFull()) {       console.log("Queue is full. Cannot enqueue.");       return;     }     queue[rear] = item;     rear = (rear + 1) % capacity;     size++;   }   function dequeue() {     if (isEmpty()) {       console.log("Queue is empty. Cannot dequeue.");       return;     }     const item = queue[front]...

Today I have learned API in javascript

 API in javascript: The GET method The GET method is used to retrieve data from the server. This is a read-only method, so it has no risk of mutating or corrupting the data. For example, if we call the get method on our API, we’ll get back a list of all to-dos. Let’s try it! Let’s set up an HTML file that you can run locally on your browser. Create a file called index.html and add in the following code: <!DOCTYPE html> <html> <body> <h1>Get hands on with JavaScript’s Fetch API</h1> <p>Write your requests in the script and watch the console and network logs.</p> <script> // GET retrieve all to-do’s fetch(‘https://jsonplaceholder.typicode.com/todos') .then(response => response.json()) .then(json => console.log(json)) // will return all resources // GET retrieves the to-do with specific URI (in this case id = 5) fetch(‘https://jsonplaceholder.typicode.com/todos/5') .then(response => response.json()) .then(json => console....

Today I have learned Image responsive in moblie view and web view in javascript

Image
  Image responsive in moblie view and web view in javascript: What are responsive images in HTML? Responsive images in HTML are images that automatically adjust their size based on the size of the screen or the container they are displayed in, providing an optimal viewing experience on different devices with varying screen sizes. Why is image responsiveness important? In today’s digital age, having an image responsive website has become essential to provide a seamless browsing experience for users across all devices. Image responsiveness ensures that your images adapt to the device’s screen size and resolution, maintaining their quality and proportion.   @media all and ( max-width : 4900px ) {     .nature {       width : 100% ;     }   }   @media all and ( max-width : 3849px ) {     .nature {       width : 80% ;     }   }   @media all and ( ma...

Today I have learned media query of web view in javascript

Image
  Media query of web view : Using Media Queries With JavaScript Media queries was introduced in CSS3, and is one of the key ingredients for responsive web design. Media queries are used to determine the width and height of a viewport to make web pages look good on all devices (desktops, laptops, tablets, phones, etc). The  window.matchMedia()  method returns a MediaQueryList object representing the results of the specified CSS media query string. The value of the matchMedia() method can be any of the media features of the  CSS @media rule , like min-height, min-width, orientation, etc. What is the best way to implement a JavaScript media query? Media query strings are defined in a JSON (or similar) file and the values are slotted into the CSS and JavaScript code at build time. In summary, the matchMedia API is likely to be the most efficient and practical way to implement a JavaScript media query. It has some quirks, but it’s the best option in most situati...

Today I have learned style in css

Image
 Style in css: What is CSS? Cascading Style Sheets (CSS) is used to format the layout of a webpage. With CSS, you can control the color, font, the size of text, the spacing between elements, how elements are positioned and laid out, what background images or background colors are to be used, different displays for different devices and screen sizes, and much more! Using CSS CSS can be added to HTML documents in 3 ways: Inline  - by using the  style  attribute inside HTML elements Internal  - by using a  <style>  element in the  <head>  section External  - by using a  <link>  element to link to an external CSS file The most common way to add CSS, is to keep the styles in external CSS files. However, in this tutorial we will use inline and internal styles, because this is easier to demonstrate, and easier for you to try it yourself. Inline CSS An inline CSS is used to apply a unique style to a single HTML elemen...