Your JS is sending the request directly, so abc_add_post()
appears to be entirely unnecessary. The issue with your JavaScript is that this part it still within the string started with "
:
xhr.setRequestHeader( 'Authentication', 'Basic ' + btoa( 'saurab:saurav123' ) );
To use a function and concatenate it you need to close the already open string:
xhr.setRequestHeader( 'Authentication', 'Basic '" + btoa( 'saurab:saurav123' ) + "');
Related Posts:
- How to add category to: ‘wp-admin/post-new.php’?
- WP Rest API v2 filter and display latest post with specific tag
- WP REST API, query total posts in a category
- Get post from custom REST endpoint in Gutenberg
- WordPress Rest API – Get all posts based on post_meta on custom endpoint
- Disable REST API for a user ROLE
- ping_status in JSON REST API
- WordPress blog posts api – get posts by author
- WP rest api returns 404 only when author param is used
- Exclude posts w/ specific post_meta on Rest API endpoint
- Add ajax load more function using WP API
- Transfer WordPress post to RoR site: is the REST Api the only and/or best solution?
- WordPress REST API not returning all posts
- Exclude post_meta from Rest API Endpoint
- WP Remote Request not returning all of content via request
- Get more than one author’s posts with REST API
- How to create a post using REST API with sending data as a JSON body?
- How can I get the media inside a post?
- Call Web Services on post first publish
- Getting featured image with PHP and not javascript from wordpress api _embed [closed]
- search blog posts by author first name and or last name
- Creating a WordPress Post via REST API – HTML or Markdown?
- How to get post with associated categories and tags names instead of ids with rest api?
- What date to use as a post date? date_gmt or modified_date_gmt
- Custom wp-query in wordpress rest api
- Filter out posts based on a certain post_meta on the WordPress REST API
- Optimal WP Web App Backend for mobile app development
- Delete Post but retain image of post [WP REST API]
- Pull in posts using post meta for REST API
- Rest API Paginate until all posts are imported
- Add a field in my rest api
- How do I assign an attachment to a post using only the REST API?
- WordPress rest API get Posts parent by post ID
- Updating post status via rest api
- exclude particular category in api
- Weird problem occurs while using WordPress REST API to create new post
- How to set the post permalink using the WordPress REST API?
- How to prevent post update using transition_post_status
- REST API Working for GET but not for POST?
- Loading posts outside wordpress
- How to create REST Based JSON API(how to modify the code below)?
- Best Way to detect unique posts in wp rest api
- WP Rest API feature image breaking react component
- Changes done in admin panel are taking time to reflect in the REST api responses
- Passing a hardcoded page/post ID into `get_post`
- MySQL Query to Retrieve Category from wp_posts
- Where does WordPress store the users customization in the theme
- Create posts on user registration
- Clear cache when a post is submitted [closed]
- get comments and get posts in loop
- Category checkbox list tree changes when editing a post
- How do I create a featured post within a custom post type?
- How do I create Comma Separated list of attached image ids?
- Rewriting WordPress core functionallity: Changing the private posts
- Post author is changed to admin after his post is modified by admin
- How can I control multiple editing of wordpress posts?
- How to update serialized post meta?
- Frontend Post Form Validation
- While in “the loop”, detect if a post is the most recent
- Edit Post VS Custom Form
- Post update RSS notification plugin
- Templating of a specific post ID
- WP_Query get posts from custom posts by category
- List posts in a given category
- Limit posts per author role (excluding admin) in home page
- I want to display custom text widgets for each post in the sidebar?
- Multi row post list
- Hook in to add new post link wp admin?
- How do I insert a post with custom post type and relate it to a custom taxonomy?
- Dynamically switch template on click
- Add field to user meta table in database when link is clicked
- How to get post content from an array of ids?
- Hide custom metabox value from custom fields
- See if a post has a specified tag
- Is there a way to order children of post?
- Need to know custom code to display random and most viewed posts in wordpress posts and pages
- How to retrieve certain number of images from a wordpress post?
- Issue with first top post display order
- Let Posts be stored in another table
- Widget to show posts in the sidebar basing on its IDs
- Display message depending on capability outside loop
- How to link post titles on page A to its posts on page B?
- ACF flexible content block not showing on live site (works locally)
- How to limit number of posts on AMP homepage
- Related post not showing table of content
- How publish post from pending status
- Template for displaying CPT / Taxonomy URL issues
- How to prevent clicking on posts
- Hiding title of selected post without plugins
- WordPress post filter
- Page 2 has no posts?
- One of my posts is displayed as page
- What is wrong with this wp_query?
- I need to create a page or post hierarchy
- Post count by Parent Category
- Automatically delete default posts and pages on theme install?
- Make ‘Page’ slug the ‘index’
- How do i retrive a post from a custom post type
- How to implement default comment section in theme template?
- How do I get content of custom post type through post ID