Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

send post request

const createPostRequest = async () => {
	try{
		const { data } = await axios.post(url, body_data, {
		   headers: {
	    	 'Authorization': `Basic ${token}`
		   },
		})
    
	    console.log(data)
	} catch (error) {
		console.log(error)
	}
}

createPostRequest();
Comment

request post

import requests
import logging

API_KEY = "xxxxxxxxxxxxxxxxxxxxxxx"
API_ENDPOINT = "https://sample.endpoint.php"
try:
       # your source data eg format
       source_data = {"key":list(values)}
  
       # header to be sent to api
       headers = {"api-key" : API_KEY}
  
       # sending post request and saving response as response object
       r = requests.post(url = API_ENDPOINT, json=source_data, headers=headers)
  
       logging.info("Data push was completed with status code :"+str(r.status_code))
except requests.exceptions.RequestException as e:
       logging.info("error occured : "+ str(e) +"
status code:"+str(r.status_code))
Comment

Send the POST Request

const configurationObject = {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Accept: "application/json",
  },
  body: JSON.stringify({
    dogName: "Byron",
    dogBreed: "Poodle",
  }),
};

fetch("http://localhost:3000/dogs", configurationObject);
Comment

PREVIOUS NEXT
Code Example
Javascript :: jason in javascript 
Javascript :: html canvas not clearing 
Javascript :: javascript getters and setters 
Javascript :: how to export multiple functions react from one file 
Javascript :: javascript get last element in an array 
Javascript :: react build blank page 
Javascript :: moment 
Javascript :: vuejs transform observer to object 
Javascript :: jquery onlcikc css 
Javascript :: java script remove last charecter from the string 
Javascript :: jquery find input type password 
Javascript :: node-schedule npm 
Javascript :: react native font awesome 
Javascript :: nodejs create tree from directories 
Javascript :: get static props 
Javascript :: javascript sort array of objects by value of key in object 
Javascript :: Date object for local time and date 
Javascript :: index of 
Javascript :: how to test if an element has a class in testing library 
Javascript :: component vs container react 
Javascript :: how to import npm module 
Javascript :: get date from datepicker 
Javascript :: next-dev.js?3515:32 Warning: Prop `className` did not match. Server Client 
Javascript :: fizz buzz program in javascript 
Javascript :: onchange on multiple ids jquery 
Javascript :: js clearect 
Javascript :: code intialization problem javascript 
Javascript :: convert string to lowercase javascript 
Javascript :: settimeout method 
Javascript :: mongoose connection increase timeout in node js 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =