Most recent guests have used React Native's own blog client. When the client invokes the WordPress Rest API, some operations require HTTP authentication. In HTTP authentication, the "Authorization" field is added to the header of the HTTP request. The contents of the field when the user name: base64 encoding of the password
Environmental dependence
The Base64 codec algorithm is supported in the Nodejs buffer component. First we need to run the command line to install the buffer dependencies in the root directory of the React Native project: npm install buffer --save After installing, the app.json in the root directory of React Native The dependencies will automatically add the following one:

How to use
Introduce
Var Buffer = require('buffer').Buffer
coding
Var base64Str= new Buffer(rawStr).toString('base64');
decoding
1 2 |
Var b = new Buffer(base64Str, 'base64') Var s = b.toString(); |
Buffer project home page:
For more ways to use buffers, refer to the Buffer home page: https://github.com/feross/buffer
This article has been printed on copyright and is protected by copyright laws. It must not be reproduced without permission.If you need to reprint, please contact the author or visit the copyright to obtain the authorization. If you feel that this article is useful to you, you can click the "Sponsoring Author" below to call the author!
Reprinted Note Source: Baiyuan's Blog>>https://wangbaiyuan.cn/en/adding-base64-react-native-support-2.html
No Comment