Why don't I have any JSON showing and a 403 message? - javascript

I completely new to Strapi. However, I have used Vue CLI many times before.
I am following this tutorial on how to use the two platforms together [https://blog.logrocket.com/how-to-build-an-ecommerce-site-with-strapi-vue-js-and-flutterwave/][1].
After creating a list of products within Strapi, as in the tutorial, when I navigate to 'localhost:1337/products' I do not see any json being produced. Instead, I am presented with the following message:
{"statusCode":403,"error":"Forbidden","message":"Forbidden"}
My Vue v-for loop reports that my data is undefined as a result.
Any help welcome.

This had to do with Strapi Roles & Permissions. Once updated the data then worked.

Related

How to pull data from the Directus database to the site?

I created a database in Directus. I created a separate project for the site, where I will add data. Installed # directus / sdk.
image
But when importing, I get an error
Uncaught SyntaxError: Cannot use import statement outside a module
this is my code
import { Directus } from '#directus/sdk';
const directus = new Directus('https://api.example.com/');
await directus.auth.login({
email: 'admin#example.com',
password: 'pass',
});
const articles = await directus.items('articles').readMany();
console.log({
items: articles.data,
total: articles.meta.total_count,
});
How do I fix this error?
Is it correct to create a separate project for the site? Or could it be done in the same place as the database?
TLDR; The issue faced is does not appear to be an issue with Directus.
There are three different pieces of software/code that that you should be aware of.
Database.
Directus Install.
Your App.
These are three different things, make sure you're clear on the difference. The database will be stored in your database of choice, MySQL, Postgres etc... Directus only connects to this and it will remain should you decide to stop using Directus for any reason.
You will need to install Directus in one location. You will then need to write your application in another location, where you may use the SDK for easy Directus API usage within your app.
It is correct (as you asked) to have your application as a separate "project".
The reason you are getting the error Cannot use import statement outside a module is not related to Directus. This is a common error when you are building or compiling your application incorrectly (Not ES6) therefore I cannot provide much support to you.
Here are some helpful debugging resources:
https://www.google.com/search?q=cannot+use+import+statement+outside+a+module
"Uncaught SyntaxError: Cannot use import statement outside a module" when importing ECMAScript 6
https://exerror.com/uncaught-syntaxerror-cannot-use-import-statement-outside-a-module-when-importing-ecmascript-6/

Firebase console is not showing updated data

I am writing data to Firebase using the following code:
firebase.database().ref('cards/1').set({
val:1
});
I then retrieve the data using the following code:
firebase.database().ref('cards/1').once('value').then(function(snapshot) {
console.info('Getting value from database:')
console.info(snapshot)
})
The code above works fine and is displaying correct result. However firebase console is not reflecting the update. I even tried logging out and back in. What am I doing wrong?
Didn't work for me either.
But to get latest logs, run this command in your terminal: firebase functions:log
You can see the updated logs.
I had the same problem, my documents were not showing in Firebase Console.
According to the Usage and billing page:
The resources available to you in the plans are capped. If your
project exceeds a limit, services may be disabled for that product.
After I upgraded, it started working again.
This could be because you have reached your daily quota.
If you click on the 'billing and quota usage' link on your Usage Over Time you can check if you have reached your quota.
I had the same problem, although I was using Firebase on Android. My issue was that for some reason, the SDK was providing me with an instance set in another location from the one I specified during the setup. To solve this, I had to provide the URL of the database, got the right reference from there, and the data was being updated.

How to parse error with Square Connect API example (Node)

I am trying to learn how to process payments with Square, and am trying to run their examples from GitHub to get a feel regarding how to structure the payments application. I built the node example from here: https://github.com/square/connect-api-examples/tree/master/connect-examples/v2/node_payment using npm install and npm build to get the app up and running.
I am using "4532759734545858" for the card number, "123" for CVV, "0120" for expiration, and "94103" for the zip. I got the card number from here: https://docs.connect.squareup.com/articles/using-sandbox where it states that this is a good number to use for a Visa sandbox.
Also, I have updated the config.json with properties from my developer settings.
When trying to process a payment a get a DOM element that says "Card Declined" without further specifying the error. Is there something I can do to parse the error?
Based on the documentation at: https://docs.connect.squareup.com/articles/using-sandbox#generatingerrorstates it seems the amount_money field of the request is not being populated, but I am having trouble confirming.
Ideally I would like to get to a point where I can add a card as a hash value to my db and use it for recurring billing...
That "card declined" message is actually the error you get back from Square's APIs. You can play around with the error messaging in the app.js file and the `error.jade. Try error.catagory, code, detail.
Keep in mind that this is just a sample app, to show that you can use the APIs with node.js, you probably don't want to use this code in your production system.

Ionic 2 + AngularFire2 (TypeScript/JavaScript): Not able to properly iterate over Array

I am currently using Ionic 2 (which is based on Angular 2) to develop a Progressive Web Application about food and restaurants.
I use Firebase to manage my Users and more generaly as a way to save my data.
I also use the AngularFire2 library to communicate with Firebase.
The problem I am having right now is that have a list of dishes that my clients prefer that is saved in FireBase and I want to retrieve that in order to manipulate the data and use it in a certain algorithm to be able to make propositions on what menus the client could want to eat today.
I use this code to iterate over the FirebaseListObservable that has the user's preferences:
this.af.database.list('/users/'+this.authentificationService.getUserId()+'/favs')
.subscribe(snapshots=>{
snapshots.forEach(snapshot => {
this.prefList.push(snapshot.label);
});
});
console.log(this.prefList);
And you can see that I push the values in that Observable into a list named prefList that I declared as follows:
public prefList: String[]=[];
The console.log(this.prefList) line gives me this result (as seen from Chrome's inspect >> console) As you can see the array isn't empty.
console.log(this.pref)
The problem is that I cannot iterate over the prefList because the length seems to always be 0. I tried with this.pref[0] aswell but this time I get Undefined. I really can't see a way to solve this. Please help?

Access server files with ArcGIS javascript api

I have a geoprocessing service that takes two parameters: netCDF (file) and Date (str). I'm working off of the demo found here.
The issue I have is getting the netCDF file to the geoprocessing service. By creating an upload feature I can see how I would be able to provide the needed parameter but I already have all the necessary files server side.
How can I get my web application to read local netCDF data into the geoprocessing service?
Any suggestions would be greatly appreciated.
My testing application can be found here.
Service: http://sroarcgis.ducks.org/ducksunlimited/rest/services/wsi_tool/GPServer
I receiver the error message: Error {code: 400, message: "Invalid or missing input parameters.", details: Array[0], log: undefined, httpCode: 400}
Thanks!
I'm not sure if this applies to your geoprocess, but I got this same error message and I finally fixed my problem:
Make sure you have the same fields in the search results as you have in the table the search is linked to.
It was a simple fix that took me awhile to find (as these things usually go). I had included a field that was visible in other tables, but that I had had turned off in this table before publishing the map.
Hope this helps!
After speaking with ESRI support they said that I would need to enable uploads on my web server, then upload each file individually.
Regarding your "Invalid or missing input parameters." error, you may be able to resolve this error using the following steps:
Log into ArcCatalog
Create a database connection as the user who is the owner of the table.
Select the table in the Catalog Tree.
Click the Preview tab. (Not sure if this step is really needed, but it will confirm that the metadata was refreshed properly.)
This error can crop up if the table columns change in some way. I think this process refreshes the SDE Metadata associated with the table.

Categories

Resources